fix(schedule): use should-be-displayed result for tutorial actions
This commit is contained in:
parent
601cb3179f
commit
3919152ede
@ -213,20 +213,14 @@ getCShowR tid ssh csh = do
|
||||
| isRegistered -> return [whamlet|_{MsgTutorialRegistered}|]
|
||||
| otherwise -> return mempty
|
||||
tutScheduleOptSet <- if
|
||||
| Just (uid,User{..}) <- mbAuth -> do
|
||||
mTutorialScheduleOpt <- getBy $ UniqueTutorialScheduleOpt tutId uid
|
||||
let
|
||||
currentOpt = maybe
|
||||
( maybe
|
||||
(isRegistered && userScheduleOccurrenceDisplayDefault)
|
||||
((&&) isRegistered . courseScheduleOptOpt . entityVal)
|
||||
mCourseScheduleOpt
|
||||
)
|
||||
(tutorialScheduleOptOpt . entityVal)
|
||||
mTutorialScheduleOpt
|
||||
(tutScheduleForm, tutScheduleEnctype) <- liftHandler . generateFormPost . buttonForm' $ bool [BtnScheduleOptIn] [BtnScheduleOptOut] currentOpt
|
||||
| Just (uid,_) <- mbAuth -> do
|
||||
shouldBeDisplayedInSchedule <- E.selectExists . E.from $ \(c `E.InnerJoin` tut) -> do
|
||||
E.on $ c E.^. CourseId E.==. tut E.^. TutorialCourse
|
||||
E.where_ $ tut E.^. TutorialId E.==. E.val tutId
|
||||
E.&&. tutorialShouldBeDisplayedInSchedule (Just uid) ata c tut
|
||||
(tutScheduleForm, tutScheduleEnctype) <- liftHandler . generateFormPost . buttonForm' $ bool [BtnScheduleOptIn] [BtnScheduleOptOut] shouldBeDisplayedInSchedule
|
||||
return $ wrapForm tutScheduleForm def
|
||||
{ formAction = Just . SomeRoute $ CTutorialR tid ssh csh tutorialName (TScheduleOptSetR $ not currentOpt)
|
||||
{ formAction = Just . SomeRoute $ CTutorialR tid ssh csh tutorialName (TScheduleOptSetR $ not shouldBeDisplayedInSchedule)
|
||||
, formEncoding = tutScheduleEnctype
|
||||
, formSubmit = FormNoSubmit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user