feat(pages.py): delete event's future occurrences if unpublished

This commit is contained in:
2026-04-23 18:17:20 +02:00
parent 6d355b603d
commit 97df6349ab

View File

@@ -328,6 +328,12 @@ class EventPage(Page):
from .event_occurrence import EventOccurrence
now = timezone.now()
if not self.live:
# if not live, no future occurrences should be generated
self.occurrences.filter(start__gt=now).delete()
return
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
@@ -379,8 +385,7 @@ class EventPage(Page):
def save(self, *args, **kwargs):
super().save(*args, **kwargs)
if self.live:
self.generate_occurrences()
self.generate_occurrences()
content_panels = Page.content_panels + [
FieldPanel("tags"),