Fix critical error in previous commit

This commit is contained in:
Raphael Michel
2019-06-10 17:18:08 +02:00
parent 61e111742d
commit 49c4acefd0
2 changed files with 16 additions and 9 deletions

View File

@@ -244,13 +244,14 @@ class SubEventViewSet(ConditionalListView, viewsets.ModelViewSet):
)
def perform_update(self, serializer):
if serializer.data == self.get_serializer(instance=serializer.instance).data:
original_data = self.get_serializer(instance=serializer.instance).data
super().perform_update(serializer)
if serializer.data == original_data:
# Performance optimization: If nothing was changed, we do not need to save or log anything.
# This costs us a few cycles on save, but avoids thousands of lines in our log.
return
super().perform_update(serializer)
serializer.instance.log_action(
'pretix.subevent.changed',
user=self.request.user,

View File

@@ -65,11 +65,14 @@ class ItemViewSet(ConditionalListView, viewsets.ModelViewSet):
return ctx
def perform_update(self, serializer):
if serializer.data == self.get_serializer(instance=serializer.instance).data:
original_data = self.get_serializer(instance=serializer.instance).data
serializer.save(event=self.request.event)
if serializer.data == original_data:
# Performance optimization: If nothing was changed, we do not need to save or log anything.
# This costs us a few cycles on save, but avoids thousands of lines in our log.
return
serializer.save(event=self.request.event)
serializer.instance.log_action(
'pretix.event.item.changed',
user=self.request.user,
@@ -456,14 +459,17 @@ class QuotaViewSet(ConditionalListView, viewsets.ModelViewSet):
return ctx
def perform_update(self, serializer):
if serializer.data == self.get_serializer(instance=serializer.instance).data:
# Performance optimization: If nothing was changed, we do not need to save or log anything.
# This costs us a few cycles on save, but avoids thousands of lines in our log.
return
original_data = self.get_serializer(instance=serializer.instance).data
current_subevent = serializer.instance.subevent
serializer.save(event=self.request.event)
request_subevent = serializer.instance.subevent
if serializer.data == original_data:
# Performance optimization: If nothing was changed, we do not need to save or log anything.
# This costs us a few cycles on save, but avoids thousands of lines in our log.
return
serializer.instance.log_action(
'pretix.event.quota.changed',
user=self.request.user,