fix(pages.py): fix event's other occurrences not being deleted when changing event from recurrent to single
Closes #1
This commit is contained in:
@@ -330,12 +330,15 @@ class EventPage(Page):
|
||||
now = timezone.now()
|
||||
if not self.recurrence_enabled:
|
||||
# if recurrence is not enabled, ensure there's at least one occurrence for the specified start/end
|
||||
# and delete any other occurrences that don't match the current start/end
|
||||
if self.occurrences.exists():
|
||||
occurrence = self.occurrences.first()
|
||||
if occurrence.start != self.start or occurrence.end != self.end:
|
||||
occurrence.start = self.start
|
||||
occurrence.end = self.end
|
||||
occurrence.save(update_fields=["start", "end"])
|
||||
|
||||
self.occurrences.exclude(id=occurrence.id).delete()
|
||||
else:
|
||||
EventOccurrence.objects.create(
|
||||
event=self, start=self.start, end=self.end
|
||||
|
||||
Reference in New Issue
Block a user