Skip to content
Snippets Groups Projects
Commit 2c5d5826 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch '145-finally-fix-lessons_on_day-property' into 'master'

Resolve "Finally fix lessons_on_day property"

Closes #145

See merge request !183
parents ba1f822c 6f774c1d
No related branches found
No related tags found
1 merge request!183Resolve "Finally fix lessons_on_day property"
Checking pipeline status
......@@ -20,6 +20,7 @@ Fixed
* Preference section verbose names were displayed in server language and not
user language (fixed by using gettext_lazy).
* 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
--------------------
......
......@@ -83,7 +83,11 @@ def lesson_periods_as_teacher(self):
@Person.method
def lessons_on_day(self, day: date):
"""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
......
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