Skip to content
Snippets Groups Projects
Commit 46259cb0 authored by Hangzhi Yu's avatar Hangzhi Yu Committed by Hangzhi Yu
Browse files

Fix is_lesson_teacher predicate

parent 39496545
No related branches found
No related tags found
1 merge request!49Resolve "Add rules and permissions"
Pipeline #3476 passed
...@@ -20,7 +20,12 @@ def is_lesson_teacher(user: User, obj: LessonPeriod) -> bool: ...@@ -20,7 +20,12 @@ def is_lesson_teacher(user: User, obj: LessonPeriod) -> bool:
Checks whether the person linked to the user is a teacher Checks whether the person linked to the user is a teacher
in the lesson or the substitution linked to the given LessonPeriod. in the lesson or the substitution linked to the given LessonPeriod.
""" """
return user.person in Person.objects.filter(lesson_substitutions=obj.get_substitution()) if obj:
return (
user.person in obj.lesson.teachers.all()
or user.person in Person.objects.filter(lesson_substitutions=obj.get_substitution())
)
return True
@predicate @predicate
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment