feat(schedule): use occ display default for course events
This commit is contained in:
parent
ef8c572860
commit
8b49bf866e
@ -21,9 +21,10 @@ fetchActiveTerms = E.select $ E.from $ \term -> do
|
||||
fetchCourseEvents :: MonadHandler m => Maybe UserId -> AuthTagActive -> UTCTime -> ReaderT SqlBackend m [ScheduleCourseEventInfo]
|
||||
fetchCourseEvents muid ata now = E.select $ E.from $ \(course `E.InnerJoin` courseEvent) -> do
|
||||
E.on $ course E.^. CourseId E.==. courseEvent E.^. CourseEventCourse
|
||||
E.where_ $ mayViewCourse muid ata now course Nothing -- should not be necessary, but let's be on the safe side
|
||||
E.&&. ( isCourseParticipant muid ata (course E.^. CourseId)
|
||||
E.||. isCourseLecturer muid ata (course E.^. CourseId)
|
||||
E.where_ $ courseEventShouldBeDisplayed muid course courseEvent
|
||||
E.&&. mayViewCourse muid ata now course Nothing -- should not be necessary, but let's be on the safe side
|
||||
E.&&. ( isCourseParticipant muid ata (course E.^. CourseId)
|
||||
E.||. isCourseLecturer muid ata (course E.^. CourseId)
|
||||
)
|
||||
return (course, courseEvent)
|
||||
|
||||
@ -53,3 +54,14 @@ fetchExamOccurrences muid ata now = E.select $ E.from $ \(course `E.InnerJoin` e
|
||||
)
|
||||
)
|
||||
return (course, exam, examOccurrence)
|
||||
|
||||
|
||||
-- TODO: find better names
|
||||
|
||||
courseEventShouldBeDisplayed :: Maybe UserId -> E.SqlExpr (Entity Course) -> E.SqlExpr (Entity CourseEvent) -> E.SqlExpr (E.Value Bool)
|
||||
courseEventShouldBeDisplayed (Just uid) _course _courseEvent = E.exists . E.from $ \user ->
|
||||
E.where_ $ user E.^. UserId E.==. E.val uid
|
||||
E.&&. ( -- TODO: also check whether there is a display opt-in/out for this course or course event
|
||||
user E.^. UserScheduleNewCoursesDisplayDefault
|
||||
)
|
||||
courseEventShouldBeDisplayed _ _ _ = E.false
|
||||
|
||||
Reference in New Issue
Block a user