diff --git a/pandora/event/models.py b/pandora/event/models.py index 9fb8e96be..3bfb31905 100644 --- a/pandora/event/models.py +++ b/pandora/event/models.py @@ -98,7 +98,6 @@ class Event(models.Model): matches = [-1] return Annotation.objects.filter(id__in=matches) - @transaction.commit_on_success def update_matches(self): matches = self.get_matches() @@ -106,15 +105,21 @@ class Event(models.Model): for i in self.annotations.exclude(id__in=matches): self.annotations.remove(i) for i in matches.exclude(id__in=self.annotations.all()): - self.annotations.add(i) + #need to check again since editEvent might have been called again + if self.annotations.filter(id=i.id).count() == 0: + self.annotations.add(i) ids = list(set([a.item.id for a in matches])) for i in self.items.exclude(id__in=ids): self.items.remove(i) for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()): - self.items.add(i) - #only update matches, other values might have been changed + if self.items.filter(id=i.id).count() == 0: + self.items.add(i) if self.matches != numberofmatches: - Event.objects.filter(id=self.id).update(matches=numberofmatches) + if numberofmatches: + Event.objects.filter(id=self.id).update(matches=numberofmatches) + else: + self.matches = numberofmatches + self.save() def set_name_sort(self, value=None): if not value: diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index ce905008c..3f96bb844 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -292,14 +292,14 @@ "title": "Saturation", "type": "float", "columnWidth": 90, - "format": {"type": "color", "args": ["greyscale"]} + "format": {"type": "color", "args": ["saturation"]} }, { "id": "lightness", "title": "Lightness", "type": "float", "columnWidth": 90, - "format": {"type": "color", "args": ["greyscale"]} + "format": {"type": "color", "args": ["lightness"]} }, { "id": "volume", diff --git a/pandora/place/models.py b/pandora/place/models.py index 882492ce7..45afb55d1 100644 --- a/pandora/place/models.py +++ b/pandora/place/models.py @@ -132,12 +132,15 @@ class Place(models.Model): for i in self.annotations.exclude(id__in=matches): self.annotations.remove(i) for i in matches.exclude(id__in=self.annotations.all()): - self.annotations.add(i) + #need to check again since editEvent might have been called again + if self.annotations.filter(id=i.id).count() == 0: + self.annotations.add(i) ids = list(set([a.item.id for a in matches])) for i in self.items.exclude(id__in=ids): self.items.remove(i) for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()): - self.items.add(i) + if self.items.filter(id=i.id).count() == 0: + self.items.add(i) if self.matches != numberofmatches: if numberofmatches: Place.objects.filter(id=self.id).update(matches=numberofmatches)