From cb766968cd92f625a91fd8d8ae3c76878760edf8 Mon Sep 17 00:00:00 2001
From: Jonathan Weth <git@jonathanweth.de>
Date: Tue, 15 Jun 2021 17:18:10 +0200
Subject: [PATCH] Revert "Fix detection of the end of the validity ranges list
 in next_lessons"

This reverts commit a23a9462614bbe0b2b4769a60fd831beb1df7425.
---
 CHANGELOG.rst                    | 1 -
 aleksis/apps/chronos/managers.py | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 94c227f1..f61c4ed0 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -21,7 +21,6 @@ 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 d03589aa..042d91a6 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) - 1:
+            if validity_index >= len(validity_ranges):
                 # There are no validity ranges (and thus no lessons)
                 # in the school term after this lesson period
                 return None
-- 
GitLab