return html value for entities

This commit is contained in:
j 2015-02-06 15:11:19 +05:30
parent d492619be6
commit ad8db3a293
3 changed files with 4 additions and 3 deletions

View file

@ -228,7 +228,7 @@ class Annotation(models.Model):
try:
entity = Entity.get(self.value)
j['entity'] = entity.json(user=user)
j['value'] = entity.name
j['value'] = entity.html_link()
except:
j['entity'] = {}
elif l['type'] == 'event':

View file

@ -283,8 +283,7 @@ def editAnnotation(request, data):
try:
value = Entity.get_by_name(data['value'], layer['entity']).get_id()
except Entity.DoesNotExist:
response['data'] = a.json()
response['data']['editable'] = True
response = json_response({})
response['status']['text'] = 'unkown entity'
return render_to_json_response(response)
else:

View file

@ -141,6 +141,8 @@ class Entity(models.Model):
response[key] = self.data[key]
return response
def html_link(self):
return '<a href="/entities/%s">%s</a>' % (self.get_id(), ox.escape_html(self.name))
def update_matches(self):
import annotation.models