Skip to content

Commit bb89cac

Browse files
committed
Upon modification of Event’s interval/bookable fields, cascade those changes to all associated Occurrences
1 parent ca60ed8 commit bb89cac

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

backend/ohq_schedule/models/events.py

+11
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ def clean(self):
113113
raise ValidationError({'bookable': _('Bookable events must have an interval set')})
114114

115115
def save(self, *args, **kwargs):
116+
if self.pk is not None:
117+
original_event = Event.objects.get(pk=self.pk)
118+
119+
if original_event.interval != self.interval or original_event.bookable != self.bookable:
120+
self.clean()
121+
super().save(*args, **kwargs)
122+
self.occurrence_set.all().update(
123+
interval=self.interval,
124+
bookable=self.bookable
125+
)
126+
return
116127
self.clean()
117128
super().save(*args, **kwargs)
118129

0 commit comments

Comments
 (0)