diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index 9a27a04ea..b56a4ae2c 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -81,7 +81,7 @@ def add_annotations(data): for a in data['annotations']: if layer['type'] == 'entity': try: - value = Entity.get_by_name(a['value']).get_id() + value = Entity.get_by_name(a['value'], layer['entity']).get_id() except Entity.DoesNotExist: continue else: diff --git a/pandora/annotation/views.py b/pandora/annotation/views.py index 275c1c90a..6a6f0ba6c 100644 --- a/pandora/annotation/views.py +++ b/pandora/annotation/views.py @@ -168,7 +168,7 @@ def addAnnotation(request, data): if layer['canAddAnnotations'].get(request.user.get_profile().get_level()): if layer['type'] == 'entity': try: - value = Entity.get_by_name(data['value']).get_id() + value = Entity.get_by_name(data['value'], layer['entity']).get_id() except Entity.DoesNotExist: response = json_response({}) response['status']['text'] = 'unkown entity' @@ -281,7 +281,7 @@ def editAnnotation(request, data): if key in data: if key == 'value' and layer['type'] == 'entity': try: - value = Entity.get_by_name(data['value']).get_id() + value = Entity.get_by_name(data['value'], layer['entity']).get_id() except Entity.DoesNotExist: response['data'] = a.json() response['data']['editable'] = True diff --git a/pandora/entity/models.py b/pandora/entity/models.py index 6e8ae8286..f9dc58783 100644 --- a/pandora/entity/models.py +++ b/pandora/entity/models.py @@ -63,8 +63,8 @@ class Entity(models.Model): return cls.objects.get(pk=ox.fromAZ(id)) @classmethod - def get_by_name(cls, name): - return cls.objects.get(name_find__icontains=u'|%s|'%name) + def get_by_name(cls, name, type): + return cls.objects.get(name_find__icontains=u'|%s|'%name, type=type) @classmethod def get_or_create(model, name):