diff --git a/src/Handler/Allocation/Show.hs b/src/Handler/Allocation/Show.hs index 6015f2820..a3df82105 100644 --- a/src/Handler/Allocation/Show.hs +++ b/src/Handler/Allocation/Show.hs @@ -3,6 +3,9 @@ module Handler.Allocation.Show ) where import Import + +import Utils.Course + import Handler.Utils import Handler.Allocation.Register @@ -32,13 +35,14 @@ getAShowR tid ssh ash = do courses <- E.select . E.from $ \((allocationCourse `E.InnerJoin` course) `E.LeftOuterJoin` courseApplication `E.LeftOuterJoin` registration) -> do E.on $ registration E.?. CourseParticipantCourse E.==. E.just (course E.^. CourseId) - E.&&. registration E.?. CourseParticipantUser E.==. E.val muid - E.&&. registration E.?. CourseParticipantState E.==. E.just (E.val CourseParticipantActive) + E.&&. registration E.?. CourseParticipantUser E.==. E.val muid + E.&&. registration E.?. CourseParticipantState E.==. E.just (E.val CourseParticipantActive) E.on $ courseApplication E.?. CourseApplicationCourse E.==. E.just (course E.^. CourseId) - E.&&. courseApplication E.?. CourseApplicationUser E.==. E.val muid - E.&&. courseApplication E.?. CourseApplicationAllocation E.==. E.just (E.just $ E.val aId) + E.&&. courseApplication E.?. CourseApplicationUser E.==. E.val muid + E.&&. courseApplication E.?. CourseApplicationAllocation E.==. E.just (E.just $ E.val aId) E.on $ allocationCourse E.^. AllocationCourseCourse E.==. course E.^. CourseId E.where_ $ allocationCourse E.^. AllocationCourseAllocation E.==. E.val aId + E.&&. mayViewCourse muid now course E.orderBy [E.asc $ course E.^. CourseName] let hasTemplate = E.exists . E.from $ \courseAppInstructionFile -> E.where_ $ courseAppInstructionFile E.^. CourseAppInstructionFileCourse E.==. course E.^. CourseId @@ -73,12 +77,14 @@ getAShowR tid ssh ash = do setTitleI shortTitle let courseWidgets = flip map courses $ \cEntry -> do - let Entity cid Course{..} = cEntry ^. resultCourse - hasApplicationTemplate = cEntry ^. resultHasTemplate - mApp = cEntry ^? resultCourseApplication - isRegistered = cEntry ^. resultIsRegistered + let Entity cid c@Course{..} = cEntry ^. resultCourse + hasApplicationTemplate = cEntry ^. resultHasTemplate + mApp = cEntry ^? resultCourseApplication + isRegistered = cEntry ^. resultIsRegistered + courseVisible = courseIsVisible' now c cID <- encrypt cid :: WidgetFor UniWorX CryptoUUIDCourse mayApply <- hasWriteAccessTo . AllocationR tid ssh ash $ AApplyR cID + mayEdit <- hasWriteAccessTo $ CourseR tid ssh courseShorthand CEditR isLecturer <- hasWriteAccessTo $ CourseR courseTerm courseSchool courseShorthand CEditR mApplyFormView <- liftHandler . for muid $ \uid -> generateFormPost . applicationForm (Just aId) cid uid $ ApplicationFormMode True mayApply isLecturer tRoute <- case mApp of diff --git a/templates/allocation/show/course.hamlet b/templates/allocation/show/course.hamlet index ef2a7341f..b5314cb99 100644 --- a/templates/allocation/show/course.hamlet +++ b/templates/allocation/show/course.hamlet @@ -12,6 +12,8 @@ $if is _Just muid _{MsgAllocationNoApplication} #{courseName} + $if not courseVisible && mayEdit + \ #{iconInvisible} $if hasApplicationTemplate || is _Just courseApplicationsInstructions
_{MsgCourseApplicationInstructionsApplication}