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

Fix lessons_on_day to work correctly if a person has no lessons

parent ba1f822c
No related branches found
No related tags found
1 merge request!183Resolve "Finally fix lessons_on_day property"
Pipeline #16686 passed
...@@ -20,6 +20,7 @@ Fixed ...@@ -20,6 +20,7 @@ Fixed
* Preference section verbose names were displayed in server language and not * Preference section verbose names were displayed in server language and not
user language (fixed by using gettext_lazy). user language (fixed by using gettext_lazy).
* Affected groups and persons in substitutions list were displayed multiple times. * Affected groups and persons in substitutions list were displayed multiple times.
* ``lessons_on_day`` didn't work as expected if a person has no lessons.
`2.0b2` - 2021-06-02 `2.0b2` - 2021-06-02
-------------------- --------------------
......
...@@ -83,7 +83,11 @@ def lesson_periods_as_teacher(self): ...@@ -83,7 +83,11 @@ def lesson_periods_as_teacher(self):
@Person.method @Person.method
def lessons_on_day(self, day: date): def lessons_on_day(self, day: date):
"""Get all lessons of this person (either as participant or teacher) on the given day.""" """Get all lessons of this person (either as participant or teacher) on the given day."""
return LessonPeriod.objects.on_day(day).filter_from_person(self).order_by("period__period") qs = LessonPeriod.objects.on_day(day).filter_from_person(self)
if qs:
# This is a union queryset, so order by must be after the union.
return qs.order_by("period__period")
return None
@Person.method @Person.method
......
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