don't fail on removed layers

This commit is contained in:
j 2017-07-26 13:31:57 +02:00
parent dacbdf45f8
commit 41d4e52f84

View file

@ -330,24 +330,25 @@ class Annotation(models.Model):
if self.languages: if self.languages:
j['languages'] = self.languages.split(',') j['languages'] = self.languages.split(',')
l = self.get_layer() l = self.get_layer()
if l['type'] == 'entity': if l:
try: if l['type'] == 'entity':
(j['entity'], j['value']) = self._get_entity_json( try:
user=user, entity_cache=entity_cache) (j['entity'], j['value']) = self._get_entity_json(
except: user=user, entity_cache=entity_cache)
j['entity'] = {} except:
elif l['type'] == 'event': j['entity'] = {}
qs = self.events.all() elif l['type'] == 'event':
if qs.count() > 0: qs = self.events.all()
j['event'] = qs[0].json(user=user) if qs.count() > 0:
else: j['event'] = qs[0].json(user=user)
j['event'] = {} else:
elif l['type'] == 'place': j['event'] = {}
qs = self.places.all() elif l['type'] == 'place':
if qs.count() > 0: qs = self.places.all()
j['place'] = qs[0].json(user=user) if qs.count() > 0:
else: j['place'] = qs[0].json(user=user)
j['place'] = {} else:
j['place'] = {}
if layer or (keys and 'layer' in keys): if layer or (keys and 'layer' in keys):
j['layer'] = self.layer j['layer'] = self.layer