diff --git a/src/Handler/Course/Edit.hs b/src/Handler/Course/Edit.hs index 55e025adb..fef09d719 100644 --- a/src/Handler/Course/Edit.hs +++ b/src/Handler/Course/Edit.hs @@ -106,6 +106,7 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse . validateFormDB -- TODO: Refactor to avoid the four repeated calls to liftHandler and three runDBs -- let editCid = cfCourseId =<< template -- possible start for refactoring + now <- liftIO getCurrentTime MsgRenderer mr <- getMsgRenderer uid <- liftHandler requireAuthId @@ -194,11 +195,12 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse . validateFormDB unliftEither (Right (lid , lType )) = (Right lid , Just lType) unliftEither (Left (lEmail, mLType)) = (Left lEmail, mLType ) - (newRegFrom,newRegTo,newDeRegUntil) <- case template of - (Just cform) | (Just _cid) <- cfCourseId cform -> return (Nothing,Nothing,Nothing) + (newVisFrom,newRegFrom,newRegTo,newDeRegUntil) <- case template of + (Just cform) | (Just _cid) <- cfCourseId cform -> return (Nothing,Nothing,Nothing,Nothing) _allIOtherCases -> do mbLastTerm <- liftHandler $ runDB $ selectFirst [TermActive ==. True] [Desc TermName] - return ( (Just . toMidnight . termStart . entityVal) <$> mbLastTerm + return ( Just (Just now) + , (Just . toMidnight . termStart . entityVal) <$> mbLastTerm , (Just . beforeMidnight . termEnd . entityVal) <$> mbLastTerm , (Just . beforeMidnight . termEnd . entityVal) <$> mbLastTerm ) @@ -218,7 +220,6 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse . validateFormDB E.||. allocation E.^. AllocationSchool `E.in_` E.valList adminSchools return (allocation, alreadyParticipates) - now <- liftIO getCurrentTime let allocationEnabled :: Entity Allocation -> Bool allocationEnabled (Entity _ Allocation{..}) @@ -278,7 +279,7 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse . validateFormDB <*> aopt (urlField & cfStrip) (fslpI MsgCourseHomepageExternal (mr MsgCourseHomepageExternalPlaceholder)) (cfLink <$> template) <*> aopt utcTimeField (fslpI MsgCourseVisibleFrom (mr MsgDate) - & setTooltip MsgCourseVisibleFromTip) (cfVisFrom <$> template) + & setTooltip MsgCourseVisibleFromTip) (deepAlt (cfVisFrom <$> template) newVisFrom) <*> aopt utcTimeField (fslpI MsgCourseVisibleTo (mr MsgDate) & setTooltip MsgCourseVisibleToTip) (cfVisTo <$> template) <*> apopt checkBoxField (fslI MsgMaterialFree) (cfMatFree <$> template)