forked from 0x2620/pandora
entity names are only unique by type
This commit is contained in:
parent
e61f742d3e
commit
d492619be6
3 changed files with 5 additions and 5 deletions
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in a new issue