delete undefined places/events that do not match anymore

This commit is contained in:
j 2012-02-03 13:53:48 +05:30
parent f2fd897ce0
commit 23d4afd9c0

View file

@ -9,11 +9,9 @@ import models
def update_matching_events(id): def update_matching_events(id):
from event.models import Event from event.models import Event
a = models.Annotation.objects.get(pk=id) a = models.Annotation.objects.get(pk=id)
''' for e in a.events.filter(defined=False).exclude(name=a.value):
for e in a.events.filter(defined=False):
if e.annotations.exclude(id=id).count() == 0: if e.annotations.exclude(id=id).count() == 0:
e.delete() e.delete()
'''
if a.get_layer().get('type') == 'event' \ if a.get_layer().get('type') == 'event' \
and a.events.count() == 0: and a.events.count() == 0:
a.events.add(Event.get_or_create(a.value)) a.events.add(Event.get_or_create(a.value))
@ -31,11 +29,9 @@ def update_matching_events(id):
def update_matching_places(id): def update_matching_places(id):
from place.models import Place from place.models import Place
a = models.Annotation.objects.get(pk=id) a = models.Annotation.objects.get(pk=id)
''' for p in a.places.filter(defined=False).exclude(name=a.value):
for p in a.places.filter(defined=False):
if p.annotations.exclude(id=id).count() == 0: if p.annotations.exclude(id=id).count() == 0:
p.delete() p.delete()
'''
if a.get_layer().get('type') == 'place' \ if a.get_layer().get('type') == 'place' \
and a.places.count() == 0: and a.places.count() == 0:
a.places.add(Place.get_or_create(a.value)) a.places.add(Place.get_or_create(a.value))