Replace does not work either
This commit is contained in:
parent
8247c6c6d4
commit
075872dbbe
2
models
2
models
@ -68,7 +68,7 @@ Course
|
|||||||
hasRegistration Bool -- canRegisterNow = hasRegistration && maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo
|
hasRegistration Bool -- canRegisterNow = hasRegistration && maybe False (<= currentTime) registerFrom && maybe True (>= currentTime) registerTo
|
||||||
registerFrom UTCTime Maybe
|
registerFrom UTCTime Maybe
|
||||||
registerTo UTCTime Maybe
|
registerTo UTCTime Maybe
|
||||||
CourseTermShort termId shorthand
|
CourseTermShort termId shorthand
|
||||||
Lecturer
|
Lecturer
|
||||||
userId UserId
|
userId UserId
|
||||||
courseId CourseId
|
courseId CourseId
|
||||||
|
|||||||
@ -198,28 +198,52 @@ courseEditHandler course = do
|
|||||||
})) -> do -- edit existing course
|
})) -> do -- edit existing course
|
||||||
let tident = unTermKey tid
|
let tident = unTermKey tid
|
||||||
actTime <- liftIO getCurrentTime
|
actTime <- liftIO getCurrentTime
|
||||||
addMessage "info" [shamlet| #{show res}|]
|
addMessage "debug" [shamlet| #{show res}|]
|
||||||
runDB $ do
|
runDB $ do
|
||||||
|
old <- get cid
|
||||||
|
case old of
|
||||||
|
Nothing -> addMessageI "error" $ MsgInvalidInput
|
||||||
|
(Just oldCourse) -> do
|
||||||
-- existing <- getBy $ CourseTermShort tid csh
|
-- existing <- getBy $ CourseTermShort tid csh
|
||||||
-- if ((entityKey <$> existing) /= Just cid)
|
-- if ((entityKey <$> existing) /= Just cid)
|
||||||
-- then addMessageI "danger" $ MsgCourseEditDupShort tident csh
|
-- then addMessageI "danger" $ MsgCourseEditDupShort tident csh
|
||||||
-- else do
|
-- else do
|
||||||
addMessage "info" $ fromMaybe [shamlet|No description given.|] $ cfDesc res
|
addMessage "debug" $ fromMaybe [shamlet|No description given.|] $ cfDesc res
|
||||||
update cid
|
-- update cid
|
||||||
[ CourseName =. cfName res
|
-- [ CourseName =. cfName res
|
||||||
, CourseDescription =. cfDesc res
|
-- , CourseDescription =. cfDesc res
|
||||||
, CourseLinkExternal =. cfLink res
|
-- , CourseLinkExternal =. cfLink res
|
||||||
, CourseShorthand =. cfShort res -- TODO: change here should generate a warning, or only allowed for Admins?!
|
-- , 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?!
|
-- , CourseTermId =. tid -- TODO: change here should generate a warning, or only allowed for Admins?!
|
||||||
, CourseSchoolId =. cfSchool res
|
-- , CourseSchoolId =. cfSchool res
|
||||||
, CourseCapacity =. cfCapacity res
|
-- , CourseCapacity =. cfCapacity res
|
||||||
, CourseRegisterFrom =. cfRegFrom res
|
-- , CourseRegisterFrom =. cfRegFrom res
|
||||||
, CourseRegisterTo =. cfRegTo res
|
-- , CourseRegisterTo =. cfRegTo res
|
||||||
, CourseChangedBy =. aid
|
-- , CourseChangedBy =. aid
|
||||||
, CourseChanged =. actTime
|
-- , 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
|
addMessageI "info" $ MsgCourseEditOk tident csh
|
||||||
redirect $ CourseListTermR tid
|
redirect $ CourseListTermR tid
|
||||||
|
-- else addMessageI "danger" $ MsgCourseEditDupShort tident csh
|
||||||
|
|
||||||
(FormFailure _) -> addMessageI "warning" MsgInvalidInput
|
(FormFailure _) -> addMessageI "warning" MsgInvalidInput
|
||||||
other -> addMessage "error" $ [shamlet| Error: #{show other}|]
|
other -> addMessage "error" $ [shamlet| Error: #{show other}|]
|
||||||
|
|||||||
@ -71,3 +71,8 @@
|
|||||||
#message {
|
#message {
|
||||||
margin-bottom: 40px;
|
margin-bottom: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.alert-debug {
|
||||||
|
background-color: rgb(240, 30, 240);
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user