forked from 0x2620/pandora
only update matches if names changed
This commit is contained in:
parent
ea518c13a6
commit
7761f97090
4 changed files with 7 additions and 4 deletions
|
@ -82,7 +82,8 @@ class Event(models.Model):
|
||||||
self.items.remove(i)
|
self.items.remove(i)
|
||||||
for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()):
|
for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()):
|
||||||
self.items.add(i)
|
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):
|
def set_name_sort(self, value=None):
|
||||||
if not value:
|
if not value:
|
||||||
|
|
|
@ -87,7 +87,8 @@ def editEvent(request):
|
||||||
if 'nameSort' in data:
|
if 'nameSort' in data:
|
||||||
event.set_name_sort(data['nameSort'])
|
event.set_name_sort(data['nameSort'])
|
||||||
event.save()
|
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 = json_response(status=200, text='updated')
|
||||||
response['data'] = event.json()
|
response['data'] = event.json()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -93,7 +93,7 @@ class Place(models.Model):
|
||||||
self.items.remove(i)
|
self.items.remove(i)
|
||||||
for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()):
|
for i in Item.objects.filter(id__in=ids).exclude(id__in=self.items.all()):
|
||||||
self.items.add(i)
|
self.items.add(i)
|
||||||
self.save()
|
Place.objects.filter(id=self.id).update(matches=self.matches)
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if not self.name_sort:
|
if not self.name_sort:
|
||||||
|
|
|
@ -106,7 +106,8 @@ def editPlace(request):
|
||||||
value = tuple(value)
|
value = tuple(value)
|
||||||
setattr(place, key, value)
|
setattr(place, key, value)
|
||||||
place.save()
|
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())
|
response = json_response(place.json())
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403,
|
response = json_response(status=403,
|
||||||
|
|
Loading…
Reference in a new issue