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