Skip to content
Snippets Groups Projects
Verified Commit ef912d54 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Remove lesson replaced by events from "My timetable"

parent 1758e7cb
No related branches found
No related tags found
1 merge request!311Resolve "Lessons doesn't get cancelled by events in "My timetable""
Pipeline #145974 passed with warnings
......@@ -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
---------------------
......
......@@ -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:
......
......@@ -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_)
......
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