forked from 0x2620/pandora
merge
This commit is contained in:
commit
c8f0697a32
2 changed files with 17 additions and 7 deletions
|
@ -87,9 +87,12 @@ class Annotation(models.Model):
|
||||||
self.layer: False
|
self.layer: False
|
||||||
}).update(**{self.layer: True})
|
}).update(**{self.layer: True})
|
||||||
|
|
||||||
#how expensive is this?
|
if filter(lambda l: l['type'] == 'place' or l.get('hasPlaces'),
|
||||||
#update_matching_events.delay(self.value)
|
settings.CONFIG['layers']):
|
||||||
#update_matching_places.delay(self.value)
|
update_matching_places.delay(self.id)
|
||||||
|
if filter(lambda l: l['type'] == 'event' or l.get('hasEvents'),
|
||||||
|
settings.CONFIG['layers']):
|
||||||
|
update_matching_events.delay(self.id)
|
||||||
|
|
||||||
def json(self, layer=False, keys=None):
|
def json(self, layer=False, keys=None):
|
||||||
j = {
|
j = {
|
||||||
|
|
|
@ -2,26 +2,33 @@
|
||||||
# vi:si:et:sw=4:sts=4:ts=4
|
# vi:si:et:sw=4:sts=4:ts=4
|
||||||
from celery.task import task
|
from celery.task import task
|
||||||
|
|
||||||
|
import models
|
||||||
|
|
||||||
|
|
||||||
@task(ignore_resulsts=True, queue='default')
|
@task(ignore_resulsts=True, queue='default')
|
||||||
def update_matching_events(value):
|
def update_matching_events(id):
|
||||||
from event.models import Event
|
from event.models import Event
|
||||||
|
annotation = models.Annotation.objects.get(pk=id)
|
||||||
|
for e in annotation.events.all():
|
||||||
|
e.update_matches()
|
||||||
ids = [e['id'] for e in Event.objects.all().values('id')]
|
ids = [e['id'] for e in Event.objects.all().values('id')]
|
||||||
for i in ids:
|
for i in ids:
|
||||||
e = Event.objects.get(pk=i)
|
e = Event.objects.get(pk=i)
|
||||||
for name in [e.name] + list(e.alternativeNames):
|
for name in [e.name] + list(e.alternativeNames):
|
||||||
if name in value:
|
if name in annotation.value:
|
||||||
e.update_matches()
|
e.update_matches()
|
||||||
break
|
break
|
||||||
|
|
||||||
@task(ignore_resulsts=True, queue='default')
|
@task(ignore_resulsts=True, queue='default')
|
||||||
def update_matching_places(value):
|
def update_matching_places(id):
|
||||||
from place.models import Place
|
from place.models import Place
|
||||||
|
annotation = models.Annotation.objects.get(pk=id)
|
||||||
|
for p in annotation.places.all():
|
||||||
|
p.update_matches()
|
||||||
ids = [e['id'] for e in Place.objects.all().values('id')]
|
ids = [e['id'] for e in Place.objects.all().values('id')]
|
||||||
for i in ids:
|
for i in ids:
|
||||||
e = Place.objects.get(pk=i)
|
e = Place.objects.get(pk=i)
|
||||||
for name in [e.name] + list(e.alternativeNames):
|
for name in [e.name] + list(e.alternativeNames):
|
||||||
if name in value:
|
if name in annotation.value:
|
||||||
e.update_matches()
|
e.update_matches()
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in a new issue