SubEvent: Automatically bump all orders when date is changed

This commit is contained in:
Raphael Michel
2020-08-26 11:00:43 +02:00
parent 0bfc436970
commit 7a3418e32f
2 changed files with 52 additions and 0 deletions

View File

@@ -1113,12 +1113,28 @@ class SubEvent(EventMixin, LoggedModel):
if self.event and clear_cache:
self.event.cache.clear()
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.__original_dates = (self.date_from, self.date_to)
def save(self, *args, **kwargs):
from .orders import Order
clear_cache = kwargs.pop('clear_cache', False)
super().save(*args, **kwargs)
if self.event and clear_cache:
self.event.cache.clear()
if (self.date_from, self.date_to) != self.__original_dates:
"""
This is required to guarantee a synchronization invariant of our scanning apps.
Our syncing apps throw away order records of subevents more than X days ago, since
they are not interesting for ticket scanning and pose a performance hazard. However,
the app needs to know when a subevent is moved to a date in the future, since that
might require it to re-download and re-store the orders.
"""
Order.objects.filter(all_positions__subevent=self).update(last_modified=now())
@staticmethod
def clean_items(event, items):
for item in items: