diff --git a/src/Handler/Course/Application/Edit.hs b/src/Handler/Course/Application/Edit.hs index 0ffa0f5b9..b9b51cb1d 100644 --- a/src/Handler/Course/Application/Edit.hs +++ b/src/Handler/Course/Application/Edit.hs @@ -25,13 +25,14 @@ postCAEditR tid ssh csh cID = do -> hasWriteAccessTo $ SchoolR allocationSchool SchoolEditR Nothing -> hasWriteAccessTo $ SchoolR courseSchool SchoolEditR + let afmApplicant = uid == courseApplicationUser || isAdmin afmLecturer <- hasWriteAccessTo $ CourseR courseTerm courseSchool courseShorthand CEditR - afmApplicantEdit <- hasWriteAccessTo $ CApplicationR tid ssh csh cID CAEditR -- TODO: Wrong. + mayEdit <- hasWriteAccessTo $ CApplicationR tid ssh csh cID CAEditR courseCID <- encrypt cid :: Handler CryptoUUIDCourse let afMode = ApplicationFormMode - { afmApplicant = uid == courseApplicationUser || isAdmin - , afmApplicantEdit + { afmApplicant + , afmApplicantEdit = afmApplicant && mayEdit , afmLecturer } diff --git a/src/Handler/Course/Application/List.hs b/src/Handler/Course/Application/List.hs index b9dac3f39..23ddd7d60 100644 --- a/src/Handler/Course/Application/List.hs +++ b/src/Handler/Course/Application/List.hs @@ -221,6 +221,11 @@ postCApplicationsR tid ssh csh = do participantLink uid = do cID <- encrypt uid return . SomeRoute . CourseR tid ssh csh $ CUserR cID + + applicationLink :: MonadCrypto m => CourseApplicationId -> m (SomeRoute UniWorX) + applicationLink appId = do + cID <- encrypt appId + return . SomeRoute $ CApplicationR tid ssh csh cID CAEditR dbtSQLQuery :: CourseApplicationsTableExpr -> E.SqlQuery _ dbtSQLQuery = runReaderT $ do @@ -256,7 +261,7 @@ postCApplicationsR tid ssh csh = do dbtColonnade :: Colonnade Sortable _ _ dbtColonnade = mconcat [ emptyOpticColonnade (resultAllocation . _entityVal) $ \l -> anchorColonnade (views l allocationLink) $ colAllocationShorthand (l . _allocationShorthand) - , colApplicationId (resultCourseApplication . _entityKey) + , anchorColonnadeM (views (resultCourseApplication . _entityKey) applicationLink) $ colApplicationId (resultCourseApplication . _entityKey) , anchorColonnadeM (views (resultUser . _entityKey) participantLink) $ colUserDisplayName (resultUser . _entityVal . $(multifocusL 2) _userDisplayName _userSurname) , colUserMatriculation (resultUser . _entityVal . _userMatrikelnummer) , emptyOpticColonnade (resultStudyTerms . _entityVal) colStudyTerms