Apply 1 suggestion(s) to 1 file(s)

This commit is contained in:
Wolfgang Witt 2021-03-29 10:52:45 +00:00 committed by Gregor Kleen
parent fa75d805b0
commit fcc5930a3c

View File

@ -1506,7 +1506,9 @@ tagAccessPredicate AuthCapacity = APDB $ \_ _ _ route _ -> case route of
Entity occId ExamOccurrence{..} <- $cachedHereBinary (eid, occn) . MaybeT . getBy $ UniqueExamOccurrence eid occn
registered <- $cachedHereBinary occId . lift $ fromIntegral <$> count [ ExamRegistrationOccurrence ==. Just occId, ExamRegistrationExam ==. eid ]
-- Nothing means unlimited size
guard $ maybe True (> registered) examOccurrenceCapacity
whenIsJust examOccurrenceCapacity $ \capacity ->
registered <- $cachedHereBinary occId . lift $ fromIntegral <$> count [ ExamRegistrationOccurrence ==. Just occId, ExamRegistrationExam ==. eid ]
guard $ capacity > registered
return Authorized
CTutorialR tid ssh csh tutn _ -> maybeT (unauthorizedI MsgTutorialNoCapacity) $ do
cid <- $cachedHereBinary (tid, ssh, csh) . MaybeT . getKeyBy $ TermSchoolCourseShort tid ssh csh