fix(course-edit): expand rights of allocation admins
This commit is contained in:
parent
ac03b8c238
commit
7f2dd7808e
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user