diff --git a/src/Foundation/Authorization.hs b/src/Foundation/Authorization.hs index 7fc4f1794..5e4ee19d8 100644 --- a/src/Foundation/Authorization.hs +++ b/src/Foundation/Authorization.hs @@ -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