fix findvalue for entity annotations
This commit is contained in:
parent
ccfaa7db4a
commit
f7bbcf027a
1 changed files with 14 additions and 3 deletions
|
@ -144,7 +144,15 @@ class Annotation(models.Model):
|
||||||
layer = self.get_layer()
|
layer = self.get_layer()
|
||||||
if self.value:
|
if self.value:
|
||||||
self.value = utils.cleanup_value(self.value, layer['type'])
|
self.value = utils.cleanup_value(self.value, layer['type'])
|
||||||
self.findvalue = ox.decode_html(ox.strip_tags(re.sub('<br */?>\n?', ' ', self.value))).replace('\n', ' ')
|
|
||||||
|
findvalue = self.value
|
||||||
|
try:
|
||||||
|
l = self.get_layer()
|
||||||
|
if l['type'] == 'entity':
|
||||||
|
findvalue = self.get_entity().name
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
self.findvalue = ox.decode_html(ox.strip_tags(re.sub('<br */?>\n?', ' ', findvalue))).replace('\n', ' ')
|
||||||
self.findvalue = unicodedata.normalize('NFKD', self.findvalue).lower()
|
self.findvalue = unicodedata.normalize('NFKD', self.findvalue).lower()
|
||||||
sortvalue = sort_string(self.findvalue)
|
sortvalue = sort_string(self.findvalue)
|
||||||
while sortvalue and not unicodedata.category(sortvalue[0])[0] in ('L', 'N'):
|
while sortvalue and not unicodedata.category(sortvalue[0])[0] in ('L', 'N'):
|
||||||
|
@ -203,8 +211,11 @@ class Annotation(models.Model):
|
||||||
if e.annotations.exclude(id=self.id).count() == 0:
|
if e.annotations.exclude(id=self.id).count() == 0:
|
||||||
e.delete()
|
e.delete()
|
||||||
|
|
||||||
def json(self, layer=False, keys=None, user=None):
|
def get_entity(self):
|
||||||
from entity.models import Entity
|
from entity.models import Entity
|
||||||
|
return Entity.get(self.value)
|
||||||
|
|
||||||
|
def json(self, layer=False, keys=None, user=None):
|
||||||
j = {
|
j = {
|
||||||
'user': self.user.username,
|
'user': self.user.username,
|
||||||
}
|
}
|
||||||
|
@ -226,7 +237,7 @@ class Annotation(models.Model):
|
||||||
l = self.get_layer()
|
l = self.get_layer()
|
||||||
if l['type'] == 'entity':
|
if l['type'] == 'entity':
|
||||||
try:
|
try:
|
||||||
entity = Entity.get(self.value)
|
entity = sef.get_entity()
|
||||||
j['entity'] = entity.json(user=user)
|
j['entity'] = entity.json(user=user)
|
||||||
j['value'] = entity.html_link()
|
j['value'] = entity.html_link()
|
||||||
except:
|
except:
|
||||||
|
|
Loading…
Reference in a new issue