From f76325707595787b3c77cd08db69a3516283b264 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Tue, 15 Jun 2021 17:16:24 +0200 Subject: [PATCH] Fix detection of the end of the validity ranges list in next_lessons --- CHANGELOG.rst | 1 + aleksis/apps/chronos/managers.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f61c4ed0..94c227f1 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -21,6 +21,7 @@ Fixed 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. +* End of validity ranges list wasn't detected correctly in ``next_lesson``. `2.0b2` - 2021-06-02 -------------------- diff --git a/aleksis/apps/chronos/managers.py b/aleksis/apps/chronos/managers.py index 042d91a6..d03589aa 100644 --- a/aleksis/apps/chronos/managers.py +++ b/aleksis/apps/chronos/managers.py @@ -465,7 +465,7 @@ class LessonDataQuerySet(models.QuerySet, WeekQuerySetMixin): # If date of next lesson period is out of validity range (larger) ... elif next_lesson_period_date > next_lesson_period.lesson.validity.date_end: # ... we have to get the lesson period from the next validity range - if validity_index >= len(validity_ranges): + if validity_index >= len(validity_ranges) - 1: # There are no validity ranges (and thus no lessons) # in the school term after this lesson period return None -- GitLab