From 7f2dd7808ebca01a2e2b857b67d8ebcbd12492b9 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 5 Sep 2019 14:20:46 +0200 Subject: [PATCH] fix(course-edit): expand rights of allocation admins --- src/Handler/Course/Edit.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Handler/Course/Edit.hs b/src/Handler/Course/Edit.hs index d99c5d6a4..a9121edf4 100644 --- a/src/Handler/Course/Edit.hs +++ b/src/Handler/Course/Edit.hs @@ -211,14 +211,16 @@ makeCourseForm miButtonAction template = identifyForm FIDcourse $ \html -> do E.where_ $ term E.^. TermActive E.||. alreadyParticipates + E.||. allocation E.^. AllocationSchool `E.in_` E.valList adminSchools return (allocation, alreadyParticipates) now <- liftIO getCurrentTime let allocationEnabled :: Entity Allocation -> Bool allocationEnabled (Entity _ Allocation{..}) - = NTop allocationStaffRegisterFrom <= NTop (Just now) - && NTop (Just now) <= NTop allocationStaffRegisterTo + = ( NTop allocationStaffRegisterFrom <= NTop (Just now) + && NTop (Just now) <= NTop allocationStaffRegisterTo + ) || allocationSchool `elem` adminSchools availableAllocations = availableAllocations' ^.. folded . filtered (allocationEnabled . view _1) . _1 activeAllocations = availableAllocations' ^.. folded . filtered ((&&) <$> (not <$> allocationEnabled . view _1) <*> view (_2 . _Value)) . _1 @@ -558,7 +560,7 @@ upsertAllocationCourse cid cfAllocation = do Course{..} <- getJust cid prevAllocationCourse <- getBy $ UniqueAllocationCourse cid prevAllocation <- fmap join . traverse get $ allocationCourseAllocation . entityVal <$> prevAllocationCourse - userAdmin <- hasWriteAccessTo $ SchoolR courseSchool SchoolEditR + userAdmin <- fromMaybe False <$> for prevAllocation (\Allocation{..} -> hasWriteAccessTo $ SchoolR allocationSchool SchoolEditR) doEdit <- if | userAdmin