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

Merge branch '107-_adjacent_lesson-doesn-t-respect-users-without-lessons' into 'master'

Resolve "_adjacent_lesson doesn't respect persons without lessons"

Closes #107

See merge request !126
parents fa73bb8a 5354b84b
No related branches found
No related tags found
1 merge request!126Resolve "_adjacent_lesson breaks on persons without lessons"
Pipeline #5679 passed
...@@ -83,7 +83,7 @@ def lesson_periods_as_teacher(self): ...@@ -83,7 +83,7 @@ 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") return LessonPeriod.objects.order_by("period__period").on_day(day).filter_from_person(self)
@Person.method @Person.method
...@@ -92,6 +92,10 @@ def _adjacent_lesson( ...@@ -92,6 +92,10 @@ def _adjacent_lesson(
) -> Union["LessonPeriod", None]: ) -> Union["LessonPeriod", None]:
"""Get next/previous lesson of the person (either as participant or teacher) on the same day.""" """Get next/previous lesson of the person (either as participant or teacher) on the same day."""
daily_lessons = self.lessons_on_day(day) daily_lessons = self.lessons_on_day(day)
if not daily_lessons:
return None
ids = list(daily_lessons.values_list("id", flat=True)) ids = list(daily_lessons.values_list("id", flat=True))
index = ids.index(lesson_period.pk) index = ids.index(lesson_period.pk)
......
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