Skip to content
Snippets Groups Projects
Verified Commit 9d4f45f5 authored by Lloyd Meins's avatar Lloyd Meins :thought_balloon:
Browse files

Do not show substitution on regular timetable

parent db85b7a9
No related branches found
No related tags found
1 merge request!205Resolve "Substitution is shown on regular/print timetable"
Pipeline #37890 passed
......@@ -319,7 +319,7 @@ class LessonDataQuerySet(models.QuerySet, WeekQuerySetMixin):
| Q(**{self._period_path + "lesson__groups__parent_groups__in": groups})
)
def filter_teacher(self, teacher: Union[Person, int]):
def filter_teacher(self, teacher: Union[Person, int], is_smart: bool = True):
"""Filter for all lessons given by a certain teacher."""
qs1 = self.filter(**{self._period_path + "lesson__teachers": teacher})
qs2 = self.filter(
......@@ -330,9 +330,12 @@ class LessonDataQuerySet(models.QuerySet, WeekQuerySetMixin):
}
)
return qs1.union(qs2)
if is_smart:
return qs1.union(qs2)
else:
return qs1
def filter_room(self, room: Union["Room", int]):
def filter_room(self, room: Union["Room", int], is_smart: bool = True):
"""Filter for all lessons taking part in a certain room."""
qs1 = self.filter(**{self._period_path + "room": room})
qs2 = self.filter(
......@@ -343,18 +346,21 @@ class LessonDataQuerySet(models.QuerySet, WeekQuerySetMixin):
}
)
return qs1.union(qs2)
if is_smart:
return qs1.union(qs2)
else:
return qs1
def filter_from_type(
self, type_: TimetableType, obj: Union[Person, Group, "Room", int]
self, type_: TimetableType, obj: Union[Person, Group, "Room", int], is_smart: bool = True
) -> Optional[models.QuerySet]:
"""Filter lesson data for a group, teacher or room by provided type."""
if type_ == TimetableType.GROUP:
return self.filter_group(obj)
elif type_ == TimetableType.TEACHER:
return self.filter_teacher(obj)
return self.filter_teacher(obj, is_smart=is_smart)
elif type_ == TimetableType.ROOM:
return self.filter_room(obj)
return self.filter_room(obj, is_smart=is_smart)
else:
return None
......
......@@ -76,7 +76,7 @@ def build_timetable(
if is_person:
lesson_periods = lesson_periods.filter_from_person(obj)
else:
lesson_periods = lesson_periods.filter_from_type(type_, obj)
lesson_periods = lesson_periods.filter_from_type(type_, obj, is_smart=with_holidays)
# Sort lesson periods in a dict
lesson_periods_per_period = lesson_periods.group_by_periods(is_week=is_week)
......
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