Skip to content

Commit

Permalink
fix: except should be before return
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Nov 25, 2024
1 parent 4d8db65 commit 4ca9b76
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core_courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4ca9b76

Please sign in to comment.