more fixes, AI
This commit is contained in:
@@ -159,13 +159,18 @@ class EventParticipation(models.Model):
|
||||
return self.user.username
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
prev = EventParticipation.objects.filter(event=self.event, user=self.user)
|
||||
if len(prev) == 0:
|
||||
# For new objects, just save directly
|
||||
if self.pk is None:
|
||||
super().save(*args, **kwargs)
|
||||
else:
|
||||
prev = prev[0]
|
||||
return
|
||||
|
||||
# For existing objects, only save if values changed
|
||||
try:
|
||||
prev = EventParticipation.objects.get(pk=self.pk)
|
||||
if prev.status != self.status or prev.comment != self.comment:
|
||||
super().save(*args, **kwargs)
|
||||
except EventParticipation.DoesNotExist:
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
@staticmethod
|
||||
def hasUserSetParticipationForAllEvents(user):
|
||||
|
||||
Reference in New Issue
Block a user