From 23d4afd9c0003aea59044d1edbde94d6efd8bdda Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 3 Feb 2012 13:53:48 +0530 Subject: [PATCH] delete undefined places/events that do not match anymore --- pandora/annotation/tasks.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index c6eb47e2..6d568019 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -9,11 +9,9 @@ import models def update_matching_events(id): from event.models import Event a = models.Annotation.objects.get(pk=id) - ''' - for e in a.events.filter(defined=False): + for e in a.events.filter(defined=False).exclude(name=a.value): if e.annotations.exclude(id=id).count() == 0: e.delete() - ''' if a.get_layer().get('type') == 'event' \ and a.events.count() == 0: a.events.add(Event.get_or_create(a.value)) @@ -31,11 +29,9 @@ def update_matching_events(id): def update_matching_places(id): from place.models import Place a = models.Annotation.objects.get(pk=id) - ''' - for p in a.places.filter(defined=False): + for p in a.places.filter(defined=False).exclude(name=a.value): if p.annotations.exclude(id=id).count() == 0: p.delete() - ''' if a.get_layer().get('type') == 'place' \ and a.places.count() == 0: a.places.add(Place.get_or_create(a.value))