only update matches if names changed

This commit is contained in:
j 2011-10-11 13:00:33 +02:00
parent ea518c13a6
commit 7761f97090
4 changed files with 7 additions and 4 deletions

View file

@ -82,7 +82,8 @@ class Event(models.Model):
self.items.remove(i)
for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()):
self.items.add(i)
self.save()
#only update matches, other values might have been changed
Event.objects.filter(id=self.id).update(matches=self.matches)
def set_name_sort(self, value=None):
if not value:

View file

@ -87,7 +87,8 @@ def editEvent(request):
if 'nameSort' in data:
event.set_name_sort(data['nameSort'])
event.save()
tasks.update_matches.delay(event.id)
if 'name' in data or 'alternativeNames' in data:
tasks.update_matches.delay(event.id)
response = json_response(status=200, text='updated')
response['data'] = event.json()
else:

View file

@ -93,7 +93,7 @@ class Place(models.Model):
self.items.remove(i)
for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()):
self.items.add(i)
self.save()
Place.objects.filter(id=self.id).update(matches=self.matches)
def save(self, *args, **kwargs):
if not self.name_sort:

View file

@ -106,7 +106,8 @@ def editPlace(request):
value = tuple(value)
setattr(place, key, value)
place.save()
#tasks.update_matches.delay(place.id)
if 'name' in data or 'alternativeNames' in data:
tasks.update_matches.delay(place.id)
response = json_response(place.json())
else:
response = json_response(status=403,