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
|
||||
registerFrom UTCTime Maybe
|
||||
registerTo UTCTime Maybe
|
||||
CourseTermShort termId shorthand
|
||||
CourseTermShort termId shorthand
|
||||
Lecturer
|
||||
userId UserId
|
||||
courseId CourseId
|
||||
|
||||
@ -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}|]
|
||||
|
||||
@ -71,3 +71,8 @@
|
||||
#message {
|
||||
margin-bottom: 40px;
|
||||
}
|
||||
|
||||
.alert-debug {
|
||||
background-color: rgb(240, 30, 240);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user