From ef912d54ed0f247f562c3ca4cf3244cb3d942509 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Sun, 10 Sep 2023 12:51:55 +0200 Subject: [PATCH] Remove lesson replaced by events from "My timetable" --- CHANGELOG.rst | 5 +++++ aleksis/apps/chronos/util/build.py | 11 ++++++++--- aleksis/apps/chronos/views.py | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4fed9bc5..c4910d94 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_. Unreleased ---------- +Fixed +~~~~~ + +* Remove lessons replaced by events from "My timetable" + `3.0.1`_ - 2023-07-20 --------------------- diff --git a/aleksis/apps/chronos/util/build.py b/aleksis/apps/chronos/util/build.py index a6c89a34..f79ecf64 100644 --- a/aleksis/apps/chronos/util/build.py +++ b/aleksis/apps/chronos/util/build.py @@ -34,7 +34,7 @@ def build_timetable( type_ = obj.timetable_type is_week = False - if type(date_ref) == CalendarWeek: + if isinstance(date_ref, CalendarWeek): is_week = True if type_ is None: @@ -361,17 +361,22 @@ def build_timetable( continue events_for_this_period = events_per_period.get(period, []) + events_for_replacement_for_this_period = events_for_replacement_per_period.get( + period, [] + ) lesson_periods_for_this_period = lesson_periods_per_period.get(period, []) # Add lesson periods if lesson_periods_for_this_period: - if events_for_this_period: + if events_for_replacement_for_this_period: # If there is a event in this period, # we have to check whether the actual lesson is taking place. lesson_periods_to_keep = [] for lesson_period in lesson_periods_for_this_period: - if not lesson_period.is_replaced_by_event(events_for_this_period): + if not lesson_period.is_replaced_by_event( + events_for_replacement_for_this_period + ): lesson_periods_to_keep.append(lesson_period) col += lesson_periods_to_keep else: diff --git a/aleksis/apps/chronos/views.py b/aleksis/apps/chronos/views.py index fdb6def8..a7ae9b77 100644 --- a/aleksis/apps/chronos/views.py +++ b/aleksis/apps/chronos/views.py @@ -139,7 +139,7 @@ def timetable( el = get_el_by_pk(request, type_, pk, prefetch=True) - if type(el) == HttpResponseNotFound: + if isinstance(el, HttpResponseNotFound): return HttpResponseNotFound() type_ = TimetableType.from_string(type_) -- GitLab