From 6d355b603d7a92c3c459281770c0f9150a8e7cf2 Mon Sep 17 00:00:00 2001 From: Artur Borecki Date: Thu, 23 Apr 2026 18:10:00 +0200 Subject: [PATCH] fix(pages.py): fix event's other occurrences not being deleted when changing event from recurrent to single Closes #1 --- home/models/pages.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/home/models/pages.py b/home/models/pages.py index 49c66c0..4257e5f 100644 --- a/home/models/pages.py +++ b/home/models/pages.py @@ -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