From 303617e98b12c356bbd647099e68740cd2679222 Mon Sep 17 00:00:00 2001 From: Jonathan Weth <git@jonathanweth.de> Date: Thu, 13 Aug 2020 15:40:04 +0200 Subject: [PATCH] Do not create personal notes for cancelled lesson periods in mark_absent --- aleksis/apps/alsijil/model_extensions.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/aleksis/apps/alsijil/model_extensions.py b/aleksis/apps/alsijil/model_extensions.py index 9e758d682..926a67ec3 100644 --- a/aleksis/apps/alsijil/model_extensions.py +++ b/aleksis/apps/alsijil/model_extensions.py @@ -35,12 +35,19 @@ def mark_absent( wanted_week = CalendarWeek.from_date(day) # Get all lessons of this person on the specified day - lesson_periods = self.lesson_periods_as_participant.on_day(day).filter( - period__period__gte=from_period + lesson_periods = ( + self.lesson_periods_as_participant.on_day(day) + .filter(period__period__gte=from_period) + .annotate_week(wanted_week) ) # Create and update all personal notes for the discovered lesson periods for lesson_period in lesson_periods: + sub = lesson_period.get_substitution() + if sub: + if sub.is_cancelled: + continue + personal_note, created = PersonalNote.objects.update_or_create( person=self, lesson_period=lesson_period, -- GitLab