Skip to content
Snippets Groups Projects
Verified Commit 1005ae50 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Fix that substituted lessons and supervisions has only been shown at the old teacher

parent 32570814
No related branches found
No related tags found
1 merge request!47Advanced data in timetable views
......@@ -222,7 +222,7 @@ class LessonPeriodQuerySet(LessonDataQuerySet):
if type_ == "teacher":
# Teacher
return person.lesson_periods_as_teacher
return self.filter_teacher(person)
elif type_ == "group":
# Student
......@@ -761,6 +761,18 @@ class SupervisionQuerySet(models.QuerySet):
| Q(break_item__after_period__weekday=weekday)
)
def filter_by_teacher(self, teacher: Union[Person, int]):
""" Filter for all supervisions given by a certain teacher. """
if self.count() > 0:
week = CalendarWeek(week=self[0]._week)
dates = [week[w] for w in range(0, 7)]
return self.filter(Q(substitutions__teacher=teacher, substitutions__date__in=dates) | Q(teacher=teacher))
return self
class Supervision(ExtensibleModel):
objects = models.Manager.from_queryset(SupervisionQuerySet)()
......
......@@ -61,7 +61,7 @@ def build_timetable(
week = CalendarWeek.from_date(date_ref)
else:
week = date_ref
supervisions = Supervision.objects.filter(teacher=obj).annotate_week(week)
supervisions = Supervision.objects.all().annotate_week(week).filter_by_teacher(obj)
if is_person:
supervisions.filter_by_weekday(date_ref.weekday())
......
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