From 5b041be8d926a5dfd4ee0cd9d0a0a8da3c203eab Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 3 Feb 2012 12:25:11 +0530 Subject: [PATCH] dont mingle name if its exact --- pandora/annotation/models.py | 2 +- pandora/annotation/tasks.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 3b6305bc..4fbe6a69 100644 --- a/pandora/annotation/models.py +++ b/pandora/annotation/models.py @@ -60,7 +60,7 @@ def get_matches(obj, model, layer_type): value = value.replace(name.lower(), '') for name in [obj.name] + list(obj.alternativeNames): name = name.lower() - if name in value and re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%name).findall(value): + if name in value and (exact or re.compile('((^|\s)%s([\.,;:!?\-\/\s]|$))'%name).findall(value)): matches.append(a.id) break if not matches: diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index f939fdf5..c6eb47e2 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -14,6 +14,9 @@ def update_matching_events(id): 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)) for e in a.events.all(): e.update_matches() ids = [e['id'] for e in Event.objects.all().values('id')] @@ -23,9 +26,6 @@ def update_matching_events(id): if name.lower() in a.value.lower(): e.update_matches() break - if a.get_layer().get('type') == 'event' \ - and a.events.count() == 0: - a.events.add(Event.get_or_create(a.value)) @task(ignore_resulsts=True, queue='default') def update_matching_places(id): @@ -36,6 +36,9 @@ def update_matching_places(id): 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)) for p in a.places.all(): p.update_matches() ids = [e['id'] for e in Place.objects.all().values('id')] @@ -45,6 +48,3 @@ def update_matching_places(id): if name.lower() in a.value.lower(): e.update_matches() break - if a.get_layer().get('type') == 'place' \ - and a.places.count() == 0: - a.places.add(Place.get_or_create(a.value))