This commit is contained in:
SJost 2019-01-25 10:40:18 +01:00
parent 371a9e4673
commit 30614511a5

View File

@ -1326,15 +1326,18 @@ pageActions (CourseR tid ssh csh SheetListR) =
]) ])
, menuItemModal = False , menuItemModal = False
, menuItemAccessCallback' = do , menuItemAccessCallback' = do
uid <- requireAuthId muid <- maybeAuthId
[E.Value ok] <- runDB . E.select . return . E.exists . E.from $ \(course `E.InnerJoin` sheet `E.InnerJoin` submission) -> do case muid of
E.on $ submission E.^. SubmissionSheet E.==. sheet E.^. SheetId Nothing -> return False
E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId (Just uid) -> do
E.where_ $ submission E.^. SubmissionRatingBy E.==. E.just (E.val uid) [E.Value ok] <- runDB . E.select . return . E.exists . E.from $ \(course `E.InnerJoin` sheet `E.InnerJoin` submission) -> do
E.&&. course E.^. CourseTerm E.==. E.val tid E.on $ submission E.^. SubmissionSheet E.==. sheet E.^. SheetId
E.&&. course E.^. CourseSchool E.==. E.val ssh E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId
E.&&. course E.^. CourseShorthand E.==. E.val csh E.where_ $ submission E.^. SubmissionRatingBy E.==. E.just (E.val uid)
return ok E.&&. course E.^. CourseTerm E.==. E.val tid
E.&&. course E.^. CourseSchool E.==. E.val ssh
E.&&. course E.^. CourseShorthand E.==. E.val csh
return ok
} }
, MenuItem , MenuItem
{ menuItemType = PageActionPrime { menuItemType = PageActionPrime
@ -1494,9 +1497,9 @@ pageActions (CorrectionsR) =
, menuItemIcon = Nothing , menuItemIcon = Nothing
, menuItemRoute = SomeRoute CorrectionsCreateR , menuItemRoute = SomeRoute CorrectionsCreateR
, menuItemModal = False , menuItemModal = False
, menuItemAccessCallback' = runDB $ do , menuItemAccessCallback' = runDB . maybeT (return False) $ do
uid <- liftHandlerT requireAuthId uid <- MaybeT $ liftHandlerT maybeAuthId
[E.Value sheetCount] <- E.select . E.from $ \(course `E.InnerJoin` sheet) -> do [E.Value sheetCount] <- lift . E.select . E.from $ \(course `E.InnerJoin` sheet) -> do
E.on $ course E.^. CourseId E.==. sheet E.^. SheetCourse E.on $ course E.^. CourseId E.==. sheet E.^. SheetCourse
let let
isCorrector' = E.exists . E.from $ \sheetCorrector -> E.where_ isCorrector' = E.exists . E.from $ \sheetCorrector -> E.where_
@ -1534,9 +1537,9 @@ pageActions (CorrectionsGradeR) =
, menuItemIcon = Nothing , menuItemIcon = Nothing
, menuItemRoute = SomeRoute CorrectionsCreateR , menuItemRoute = SomeRoute CorrectionsCreateR
, menuItemModal = False , menuItemModal = False
, menuItemAccessCallback' = runDB $ do , menuItemAccessCallback' = runDB . maybeT (return False) $ do
uid <- liftHandlerT requireAuthId uid <- MaybeT $ liftHandlerT maybeAuthId
[E.Value sheetCount] <- E.select . E.from $ \(course `E.InnerJoin` sheet) -> do [E.Value sheetCount] <- lift . E.select . E.from $ \(course `E.InnerJoin` sheet) -> do
E.on $ course E.^. CourseId E.==. sheet E.^. SheetCourse E.on $ course E.^. CourseId E.==. sheet E.^. SheetCourse
let let
isCorrector' = E.exists . E.from $ \sheetCorrector -> E.where_ isCorrector' = E.exists . E.from $ \sheetCorrector -> E.where_