feat(exams): auth ExamResults by ExamExamOfficeSchools
This commit is contained in:
parent
94436ee0e1
commit
29a3e24bcf
@ -34,7 +34,7 @@ resultIsSynced authId examResult = (hasSchool E.&&. allSchools) E.||. (E.not_ ha
|
|||||||
examOfficeExamResultAuth :: E.SqlExpr (E.Value UserId) -- ^ office
|
examOfficeExamResultAuth :: E.SqlExpr (E.Value UserId) -- ^ office
|
||||||
-> E.SqlExpr (Entity ExamResult)
|
-> E.SqlExpr (Entity ExamResult)
|
||||||
-> E.SqlExpr (E.Value Bool)
|
-> E.SqlExpr (E.Value Bool)
|
||||||
examOfficeExamResultAuth authId examResult = authByUser E.||. authByField E.||. authBySchool
|
examOfficeExamResultAuth authId examResult = authByUser E.||. authByField E.||. authBySchool E.||. authByExtraSchool
|
||||||
where
|
where
|
||||||
cId = E.subSelectForeign examResult ExamResultExam (\exam -> E.subSelectForeign exam ExamCourse (E.^. CourseId))
|
cId = E.subSelectForeign examResult ExamResultExam (\exam -> E.subSelectForeign exam ExamCourse (E.^. CourseId))
|
||||||
|
|
||||||
@ -67,3 +67,9 @@ examOfficeExamResultAuth authId examResult = authByUser E.||. authByField E.||.
|
|||||||
E.on $ course E.^. CourseSchool E.==. userFunction E.^. UserFunctionSchool
|
E.on $ course E.^. CourseSchool E.==. userFunction E.^. UserFunctionSchool
|
||||||
E.&&. userFunction E.^. UserFunctionFunction E.==. E.val SchoolExamOffice
|
E.&&. userFunction E.^. UserFunctionFunction E.==. E.val SchoolExamOffice
|
||||||
E.where_ $ userFunction E.^. UserFunctionUser E.==. authId
|
E.where_ $ userFunction E.^. UserFunctionUser E.==. authId
|
||||||
|
|
||||||
|
authByExtraSchool = E.exists . E.from $ \(userFunction `E.InnerJoin` examSchool) -> do
|
||||||
|
E.on $ userFunction E.^. UserFunctionFunction E.==. E.val SchoolExamOffice
|
||||||
|
E.&&. userFunction E.^. UserFunctionSchool E.==. examSchool E.^. ExamOfficeSchoolSchool
|
||||||
|
E.where_ $ examSchool E.^. ExamOfficeSchoolExam E.==. examResult E.^. ExamResultExam
|
||||||
|
E.where_ $ userFunction E.^. UserFunctionUser E.==. authId
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user