minor changes for filter dialog

This commit is contained in:
rlx 2011-06-01 22:47:15 +00:00
commit da65166776
4 changed files with 10 additions and 5 deletions

View file

@ -71,10 +71,15 @@ class Place(models.Model):
return j
def update_matches(self):
"""
import random
self.matches = random.randint(0, 100)
"""
q = Q(value__icontains=self.name)
for name in self.alternativeNames:
q = q|Q(value__icontains=name)
self.matches = Annotation.objects.filter(q).count()
self.save()
def save(self, *args, **kwargs):

View file

@ -52,7 +52,7 @@ def addPlace(request):
value = tuple(value)
setattr(place, key, value)
place.save()
tasks.update_matches.delay(place.id)
#tasks.update_matches.delay(place.id)
response = json_response(place.json())
else:
response = json_response(status=403, text='place name exists')
@ -91,7 +91,7 @@ def editPlace(request):
value = tuple(value)
setattr(place, key, value)
place.save()
tasks.update_matches.delay(place.id)
#tasks.update_matches.delay(place.id)
response = json_response(place.json())
else:
response = json_response(status=403, text='place name/geoname conflict')