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']:
|
for a in data['annotations']:
|
||||||
if layer['type'] == 'entity':
|
if layer['type'] == 'entity':
|
||||||
try:
|
try:
|
||||||
value = Entity.get_by_name(a['value']).get_id()
|
value = Entity.get_by_name(a['value'], layer['entity']).get_id()
|
||||||
except Entity.DoesNotExist:
|
except Entity.DoesNotExist:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -168,7 +168,7 @@ def addAnnotation(request, data):
|
||||||
if layer['canAddAnnotations'].get(request.user.get_profile().get_level()):
|
if layer['canAddAnnotations'].get(request.user.get_profile().get_level()):
|
||||||
if layer['type'] == 'entity':
|
if layer['type'] == 'entity':
|
||||||
try:
|
try:
|
||||||
value = Entity.get_by_name(data['value']).get_id()
|
value = Entity.get_by_name(data['value'], layer['entity']).get_id()
|
||||||
except Entity.DoesNotExist:
|
except Entity.DoesNotExist:
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
response['status']['text'] = 'unkown entity'
|
response['status']['text'] = 'unkown entity'
|
||||||
|
@ -281,7 +281,7 @@ def editAnnotation(request, data):
|
||||||
if key in data:
|
if key in data:
|
||||||
if key == 'value' and layer['type'] == 'entity':
|
if key == 'value' and layer['type'] == 'entity':
|
||||||
try:
|
try:
|
||||||
value = Entity.get_by_name(data['value']).get_id()
|
value = Entity.get_by_name(data['value'], layer['entity']).get_id()
|
||||||
except Entity.DoesNotExist:
|
except Entity.DoesNotExist:
|
||||||
response['data'] = a.json()
|
response['data'] = a.json()
|
||||||
response['data']['editable'] = True
|
response['data']['editable'] = True
|
||||||
|
|
|
@ -63,8 +63,8 @@ class Entity(models.Model):
|
||||||
return cls.objects.get(pk=ox.fromAZ(id))
|
return cls.objects.get(pk=ox.fromAZ(id))
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_by_name(cls, name):
|
def get_by_name(cls, name, type):
|
||||||
return cls.objects.get(name_find__icontains=u'|%s|'%name)
|
return cls.objects.get(name_find__icontains=u'|%s|'%name, type=type)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_or_create(model, name):
|
def get_or_create(model, name):
|
||||||
|
|
Loading…
Reference in a new issue