Skip to content
Snippets Groups Projects

Resolve "Show abbreviations in the substitution plan only once"

2 files
+ 21
5
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -545,7 +545,7 @@ class LessonSubstitutionQuerySet(LessonDataQuerySet):
"""Return all lessons which are affected by selected substitutions."""
from .models import Lesson # noaq
return Lesson.objects.filter(lesson_periods__substitutions__in=self)
return Lesson.objects.filter(lesson_periods__substitutions__in=self).distinct()
def affected_teachers(self):
"""Get affected teachers.
@@ -553,13 +553,21 @@ class LessonSubstitutionQuerySet(LessonDataQuerySet):
Return all teachers which are affected by
selected substitutions (as substituted or substituting).
"""
return Person.objects.filter(
Q(lessons_as_teacher__in=self.affected_lessons()) | Q(lesson_substitutions__in=self)
).order_by("short_name")
return (
Person.objects.filter(
Q(lessons_as_teacher__in=self.affected_lessons()) | Q(lesson_substitutions__in=self)
)
.distinct()
.order_by("short_name")
)
def affected_groups(self):
"""Return all groups which are affected by selected substitutions."""
return Group.objects.filter(lessons__in=self.affected_lessons()).order_by("short_name")
return (
Group.objects.filter(lessons__in=self.affected_lessons())
.distinct()
.order_by("short_name")
)
class DateRangeQuerySetMixin:
Loading