diff --git a/models b/models index 82094fab7..d36a1e4c2 100644 --- a/models +++ b/models @@ -68,7 +68,7 @@ Course hasRegistration Bool -- canRegisterNow = hasRegistration && maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo registerFrom UTCTime Maybe registerTo UTCTime Maybe - CourseTermShort termId shorthand + CourseTermShort termId shorthand Lecturer userId UserId courseId CourseId diff --git a/src/Handler/Course.hs b/src/Handler/Course.hs index d287e2da4..742abd7b1 100644 --- a/src/Handler/Course.hs +++ b/src/Handler/Course.hs @@ -198,28 +198,52 @@ courseEditHandler course = do })) -> do -- edit existing course let tident = unTermKey tid actTime <- liftIO getCurrentTime - addMessage "info" [shamlet| #{show res}|] + addMessage "debug" [shamlet| #{show res}|] runDB $ do + old <- get cid + case old of + Nothing -> addMessageI "error" $ MsgInvalidInput + (Just oldCourse) -> do -- existing <- getBy $ CourseTermShort tid csh -- if ((entityKey <$> existing) /= Just cid) -- then addMessageI "danger" $ MsgCourseEditDupShort tident csh -- else do - addMessage "info" $ fromMaybe [shamlet|No description given.|] $ cfDesc res - update cid - [ CourseName =. cfName res - , CourseDescription =. cfDesc res - , CourseLinkExternal =. cfLink res - , CourseShorthand =. cfShort res -- TODO: change here should generate a warning, or only allowed for Admins?! - , CourseTermId =. tid -- TODO: change here should generate a warning, or only allowed for Admins?! - , CourseSchoolId =. cfSchool res - , CourseCapacity =. cfCapacity res - , CourseRegisterFrom =. cfRegFrom res - , CourseRegisterTo =. cfRegTo res - , CourseChangedBy =. aid - , CourseChanged =. actTime - ] + addMessage "debug" $ fromMaybe [shamlet|No description given.|] $ cfDesc res +-- update cid +-- [ CourseName =. cfName res +-- , CourseDescription =. cfDesc res +-- , CourseLinkExternal =. cfLink res +-- , CourseShorthand =. cfShort res -- TODO: change here should generate a warning, or only allowed for Admins?! +-- , CourseTermId =. tid -- TODO: change here should generate a warning, or only allowed for Admins?! +-- , CourseSchoolId =. cfSchool res +-- , CourseCapacity =. cfCapacity res +-- , CourseRegisterFrom =. cfRegFrom res +-- , CourseRegisterTo =. cfRegTo res +-- , CourseChangedBy =. aid +-- , CourseChanged =. actTime +-- ] + updOkay <- replace cid ( -- TODO replaceUnique requires Eq?! + Course { courseName = cfName res + , courseDescription = cfDesc res + , courseLinkExternal = cfLink res + , courseShorthand = cfShort res + , courseTermId = cfTerm res + , courseSchoolId = cfSchool res + , courseCapacity = cfCapacity res + , courseChanged = actTime + , courseChangedBy = aid + , courseCreated = courseCreated oldCourse + , courseCreatedBy = courseCreatedBy oldCourse + , courseHasRegistration = cfHasReg res + , courseRegisterFrom = cfRegFrom res + , courseRegisterTo = cfRegTo res + } + ) +-- if (isNothing updOkay) +-- then do addMessageI "info" $ MsgCourseEditOk tident csh redirect $ CourseListTermR tid +-- else addMessageI "danger" $ MsgCourseEditDupShort tident csh (FormFailure _) -> addMessageI "warning" MsgInvalidInput other -> addMessage "error" $ [shamlet| Error: #{show other}|] diff --git a/templates/default-layout.lucius b/templates/default-layout.lucius index cc0884a30..cfdb85a35 100644 --- a/templates/default-layout.lucius +++ b/templates/default-layout.lucius @@ -71,3 +71,8 @@ #message { margin-bottom: 40px; } + +.alert-debug { + background-color: rgb(240, 30, 240); +} +