diff --git a/pandora/annotation/models.py b/pandora/annotation/models.py index 3b6305bca..4fbe6a69b 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 f939fdf5a..c6eb47e26 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))