diff --git a/aleksis/apps/alsijil/util/predicates.py b/aleksis/apps/alsijil/util/predicates.py index 4c9f369fc3be9e38a259219591be8014bcb0ec1c..6540aeb5dffd1368058a087da92c2d3bbf303f33 100644 --- a/aleksis/apps/alsijil/util/predicates.py +++ b/aleksis/apps/alsijil/util/predicates.py @@ -20,7 +20,12 @@ def is_lesson_teacher(user: User, obj: LessonPeriod) -> bool: Checks whether the person linked to the user is a teacher 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