From f1db36dd2674423385d63cf750313dc3be35acc8 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 23 Dec 2014 15:21:05 +0000 Subject: [PATCH] dont fail with no added annotations --- pandora/annotation/tasks.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index ae43f083..9a27a04e 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -77,6 +77,7 @@ def add_annotations(data): else: layer = layer[0] user = User.objects.get(username=data['user']) + annotation = None for a in data['annotations']: if layer['type'] == 'entity': try: @@ -95,11 +96,12 @@ def add_annotations(data): #update facets if needed if layer_id in item.facet_keys: item.update_layer_facet(layer_id) - Item.objects.filter(id=item.id).update(modified=annotation.modified) - annotation.item.modified = annotation.modified - annotation.item.update_find() - annotation.item.update_sort() - annotation.item.update_facets() + if annotation: + Item.objects.filter(id=item.id).update(modified=annotation.modified) + annotation.item.modified = annotation.modified + annotation.item.update_find() + annotation.item.update_sort() + annotation.item.update_facets() return True @task(ignore_results=True, queue='default')