Skip to content

Commit

Permalink
chore: use add for rdate and exdate
Browse files Browse the repository at this point in the history
  • Loading branch information
dantetemplar committed Sep 19, 2024
1 parent 26e4d08 commit 70f34d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/core_courses/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def preprocess_on_and_weeks_on(item: Item):

if self.location_item and self.location_item.on: # only on specific dates, not every week
rdates = [dtstart.replace(day=on.day, month=on.month) for on in self.location_item.on]
vevent["rdate"] = rdates
vevent.add("rdate", rdates)
# dtstart and dtend should be adapted
dtstart = dtstart.replace(day=self.location_item.on[0].day, month=self.location_item.on[0].month)
dtend = dtend.replace(day=self.location_item.on[0].day, month=self.location_item.on[0].month)
Expand Down Expand Up @@ -429,7 +429,7 @@ def preprocess_on_and_weeks_on(item: Item):
yield vevent_copy

if exdates: # ignore reccurencies in original event
vevent["exdate"] = exdates
vevent.add("exdate", exdates)
yield vevent
else: # just a single event on specific dates
yield vevent
Expand All @@ -443,7 +443,7 @@ def preprocess_on_and_weeks_on(item: Item):
vevent_copy["uid"] = self.get_uid(sequence=str(i))
vevent_copy.pop("rdate")
rdates = [dtstart.replace(day=on.day, month=on.month) for on in item.on]
vevent_copy["rdate"] = rdates
vevent_copy.add("rdate", rdates)
# adapt dtstart and dtend
_dtstart = dtstart.replace(day=item.on[0].day, month=item.on[0].month)
_dtend = dtend.replace(day=item.on[0].day, month=item.on[0].month)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_location_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@
"ONLINE ON 11/09, 313 ON 30/10",
Item(location="ONLINE", on=[ydate(day=11, month=9)], NEST=[Item(location="313", on=[ydate(day=30, month=10)])]),
),
(
"301 (ON 15/10, 29/10, 05/11)",
Item(location="301", on=[ydate(day=15, month=10), ydate(day=29, month=10), ydate(day=5, month=11)]),
),
]


Expand Down

0 comments on commit 70f34d9

Please sign in to comment.