Towards #272
This commit is contained in:
parent
1a8cafdfe8
commit
b6b6cf75bb
@ -565,6 +565,8 @@ MenuCorrections: Korrekturen
|
|||||||
MenuSubmissions: Abgaben
|
MenuSubmissions: Abgaben
|
||||||
MenuSheetList: Übungsblätter
|
MenuSheetList: Übungsblätter
|
||||||
MenuSheetNew: Neues Übungsblatt anlegen
|
MenuSheetNew: Neues Übungsblatt anlegen
|
||||||
|
MenuSheetCurrent: Akutelles Übungsblatt
|
||||||
|
MenuSheetLastInactive: Zuletzt abgegebenes Übungsblatt
|
||||||
MenuCourseEdit: Kurs editieren
|
MenuCourseEdit: Kurs editieren
|
||||||
MenuCourseNewTemplate: Als neuen Kurs klonen
|
MenuCourseNewTemplate: Als neuen Kurs klonen
|
||||||
MenuCourseDelete: Kurs löschen
|
MenuCourseDelete: Kurs löschen
|
||||||
|
|||||||
2
routes
2
routes
@ -73,6 +73,8 @@
|
|||||||
/subs CCorrectionsR GET POST
|
/subs CCorrectionsR GET POST
|
||||||
/ex SheetListR GET !registered !materials !corrector
|
/ex SheetListR GET !registered !materials !corrector
|
||||||
!/ex/new SheetNewR GET POST
|
!/ex/new SheetNewR GET POST
|
||||||
|
/ex-current SheetCurrentR GET !free -- just a redirect
|
||||||
|
/ex-lastinactive SheetLastInactiveR GET !free -- just a redirect
|
||||||
/ex/#SheetName SheetR:
|
/ex/#SheetName SheetR:
|
||||||
/ SShowR GET !timeANDregistered !timeANDmaterials !corrector
|
/ SShowR GET !timeANDregistered !timeANDmaterials !corrector
|
||||||
/edit SEditR GET POST
|
/edit SEditR GET POST
|
||||||
|
|||||||
@ -689,6 +689,14 @@ evalAccess route isWrite = do
|
|||||||
evalAccessDB :: (MonadLogger m, MonadHandler m, HandlerSite m ~ UniWorX) => Route UniWorX -> Bool -> ReaderT (YesodPersistBackend UniWorX) m AuthResult
|
evalAccessDB :: (MonadLogger m, MonadHandler m, HandlerSite m ~ UniWorX) => Route UniWorX -> Bool -> ReaderT (YesodPersistBackend UniWorX) m AuthResult
|
||||||
evalAccessDB = evalAccess
|
evalAccessDB = evalAccess
|
||||||
|
|
||||||
|
redirectAccessDB :: (MonadLogger m, MonadHandler m, HandlerSite m ~ UniWorX) => Route UniWorX -> ReaderT (YesodPersistBackend UniWorX) m a
|
||||||
|
redirectAccessDB url = do
|
||||||
|
-- must hide URL if not authorized
|
||||||
|
access <- evalAccessDB url False
|
||||||
|
case access of
|
||||||
|
Authorized -> redirect url
|
||||||
|
_ -> notFound -- permissionDeniedI maybe not always correct?
|
||||||
|
|
||||||
|
|
||||||
-- Please see the documentation for the Yesod typeclass. There are a number
|
-- Please see the documentation for the Yesod typeclass. There are a number
|
||||||
-- of settings which can be configured by overriding methods here.
|
-- of settings which can be configured by overriding methods here.
|
||||||
@ -1221,6 +1229,31 @@ pageActions (CourseListR) =
|
|||||||
]
|
]
|
||||||
pageActions (CourseR tid ssh csh CShowR) =
|
pageActions (CourseR tid ssh csh CShowR) =
|
||||||
[ MenuItem
|
[ MenuItem
|
||||||
|
{ menuItemType = PageActionPrime
|
||||||
|
, menuItemLabel = MsgMenuSheetCurrent
|
||||||
|
, menuItemIcon = Nothing
|
||||||
|
, menuItemRoute = SomeRoute $ CourseR tid ssh csh SheetCurrentR
|
||||||
|
, menuItemModal = False
|
||||||
|
, menuItemAccessCallback' = do
|
||||||
|
now <- liftIO getCurrentTime
|
||||||
|
[E.Value ok] <- runDB . E.select . return . E.exists . E.from $ \(course `E.InnerJoin` sheet) -> do
|
||||||
|
E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId
|
||||||
|
E.where_ $ sheet E.^. SheetActiveTo E.>. E.val now
|
||||||
|
E.&&. sheet E.^. SheetActiveFrom E.<=. E.val now
|
||||||
|
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
|
||||||
|
{ menuItemType = PageActionPrime
|
||||||
|
, menuItemLabel = MsgMenuSheetLastInactive
|
||||||
|
, menuItemIcon = Nothing
|
||||||
|
, menuItemRoute = SomeRoute $ CourseR tid ssh csh SheetLastInactiveR
|
||||||
|
, menuItemModal = False
|
||||||
|
, menuItemAccessCallback' = (== Authorized) <$> evalAccess (CourseR tid ssh csh CNotesR) False
|
||||||
|
}
|
||||||
|
, MenuItem
|
||||||
{ menuItemType = PageActionPrime
|
{ menuItemType = PageActionPrime
|
||||||
, menuItemLabel = MsgMenuSheetList
|
, menuItemLabel = MsgMenuSheetList
|
||||||
, menuItemIcon = Nothing
|
, menuItemIcon = Nothing
|
||||||
|
|||||||
@ -139,6 +139,42 @@ makeSheetForm msId template = identForm FIDsheet $ \html -> do
|
|||||||
, ( NTop sfSolutionFrom >= NTop (Just sfActiveTo) , render MsgSheetErrSolutionEarly)
|
, ( NTop sfSolutionFrom >= NTop (Just sfActiveTo) , render MsgSheetErrSolutionEarly)
|
||||||
] ]
|
] ]
|
||||||
|
|
||||||
|
|
||||||
|
getSheetCurrentR :: TermId -> SchoolId -> CourseShorthand -> Handler Html
|
||||||
|
getSheetCurrentR tid ssh csh = runDB $ do
|
||||||
|
now <- liftIO getCurrentTime
|
||||||
|
sheets <- E.select . E.from $ \(course `E.InnerJoin` sheet) -> do
|
||||||
|
E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId
|
||||||
|
E.where_ $ sheet E.^. SheetActiveTo E.>. E.val now
|
||||||
|
E.&&. sheet E.^. SheetActiveFrom E.<=. E.val now
|
||||||
|
E.&&. course E.^. CourseTerm E.==. E.val tid
|
||||||
|
E.&&. course E.^. CourseSchool E.==. E.val ssh
|
||||||
|
E.&&. course E.^. CourseShorthand E.==. E.val csh
|
||||||
|
E.orderBy [E.asc $ sheet E.^. SheetActiveFrom]
|
||||||
|
E.limit 1
|
||||||
|
return $ sheet E.^. SheetName
|
||||||
|
case sheets of
|
||||||
|
(E.Value shn):_ -> redirectAccessDB $ CSheetR tid ssh csh shn SShowR
|
||||||
|
_ -> notFound
|
||||||
|
|
||||||
|
getSheetLastInactiveR :: TermId -> SchoolId -> CourseShorthand -> Handler Html
|
||||||
|
getSheetLastInactiveR tid ssh csh = runDB $ do
|
||||||
|
-- TODO: deliver oldest sheet with unassigned submissions instead!!!
|
||||||
|
now <- liftIO getCurrentTime
|
||||||
|
sheets <- E.select . E.from $ \(course `E.InnerJoin` sheet) -> do
|
||||||
|
E.on $ sheet E.^. SheetCourse E.==. course E.^. CourseId
|
||||||
|
E.where_ $ sheet E.^. SheetActiveTo E.<=. E.val now
|
||||||
|
E.&&. course E.^. CourseTerm E.==. E.val tid
|
||||||
|
E.&&. course E.^. CourseSchool E.==. E.val ssh
|
||||||
|
E.&&. course E.^. CourseShorthand E.==. E.val csh
|
||||||
|
E.orderBy [E.desc $ sheet E.^. SheetActiveTo]
|
||||||
|
E.limit 1
|
||||||
|
return $ sheet E.^. SheetName
|
||||||
|
case sheets of
|
||||||
|
(E.Value shn):_ -> redirectAccessDB $ CSheetR tid ssh csh shn SShowR
|
||||||
|
_ -> notFound
|
||||||
|
|
||||||
|
|
||||||
getSheetListR :: TermId -> SchoolId -> CourseShorthand -> Handler Html
|
getSheetListR :: TermId -> SchoolId -> CourseShorthand -> Handler Html
|
||||||
getSheetListR tid ssh csh = do
|
getSheetListR tid ssh csh = do
|
||||||
muid <- maybeAuthId
|
muid <- maybeAuthId
|
||||||
|
|||||||
Reference in New Issue
Block a user