feat(pages.py): delete event's future occurrences if unpublished
This commit is contained in:
@@ -328,6 +328,12 @@ class EventPage(Page):
|
|||||||
from .event_occurrence import EventOccurrence
|
from .event_occurrence import EventOccurrence
|
||||||
|
|
||||||
now = timezone.now()
|
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 not self.recurrence_enabled:
|
||||||
# if recurrence is not enabled, ensure there's at least one occurrence for the specified start/end
|
# 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
|
# and delete any other occurrences that don't match the current start/end
|
||||||
@@ -379,7 +385,6 @@ class EventPage(Page):
|
|||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
if self.live:
|
|
||||||
self.generate_occurrences()
|
self.generate_occurrences()
|
||||||
|
|
||||||
content_panels = Page.content_panels + [
|
content_panels = Page.content_panels + [
|
||||||
|
|||||||
Reference in New Issue
Block a user