From 4ca9b76c42bd0a989c10a6eb43ae8ee89b225a88 Mon Sep 17 00:00:00 2001 From: Ruslan Bel'kov Date: Mon, 25 Nov 2024 12:24:12 +0300 Subject: [PATCH] fix: except should be before return --- src/core_courses/models.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/core_courses/models.py b/src/core_courses/models.py index dae2d0a..789eecf 100644 --- a/src/core_courses/models.py +++ b/src/core_courses/models.py @@ -393,6 +393,11 @@ def convert_weeks_on_to_only_on(item: Item): vevent["dtstart"] = icalendar.vDatetime(dtstart) vevent["dtend"] = icalendar.vDatetime(dtend) + # check for item.except_ and add exdate if needed + if self.location_item.except_: + exdates = [dtstart.replace(day=on.day, month=on.month) for on in self.location_item.except_] + vevent.add("exdate", exdates) + if not self.location_item or not self.location_item.NEST: # Simple case, only one event yield vevent return @@ -426,10 +431,6 @@ def convert_weeks_on_to_only_on(item: Item): _dtend = _dtend.replace(hour=item.till.hour, minute=item.till.minute) vevent_copy["dtend"] = icalendar.vDatetime(_dtend) yield vevent_copy - # check for item.except_ and add exdate if needed - if self.location_item.except_: - exdates = [dtstart.replace(day=on.day, month=on.month) for on in self.location_item.except_] - vevent.add("exdate", exdates) yield vevent else: # just a single event on specific dates yield vevent