dont fail with no added annotations

This commit is contained in:
j 2014-12-23 15:21:05 +00:00
parent 5c31e3870d
commit f1db36dd26

View file

@ -77,6 +77,7 @@ def add_annotations(data):
else: else:
layer = layer[0] layer = layer[0]
user = User.objects.get(username=data['user']) user = User.objects.get(username=data['user'])
annotation = None
for a in data['annotations']: for a in data['annotations']:
if layer['type'] == 'entity': if layer['type'] == 'entity':
try: try:
@ -95,11 +96,12 @@ def add_annotations(data):
#update facets if needed #update facets if needed
if layer_id in item.facet_keys: if layer_id in item.facet_keys:
item.update_layer_facet(layer_id) item.update_layer_facet(layer_id)
Item.objects.filter(id=item.id).update(modified=annotation.modified) if annotation:
annotation.item.modified = annotation.modified Item.objects.filter(id=item.id).update(modified=annotation.modified)
annotation.item.update_find() annotation.item.modified = annotation.modified
annotation.item.update_sort() annotation.item.update_find()
annotation.item.update_facets() annotation.item.update_sort()
annotation.item.update_facets()
return True return True
@task(ignore_results=True, queue='default') @task(ignore_results=True, queue='default')