From 7ef70a04e041a4b714f09b686f25470a07445fa4 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 13 Mar 2014 10:25:29 +0100 Subject: [PATCH] dont use transaction for annotation import, fixes #2356 --- pandora/annotation/tasks.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/pandora/annotation/tasks.py b/pandora/annotation/tasks.py index 6f26cb1e..c6c1f205 100644 --- a/pandora/annotation/tasks.py +++ b/pandora/annotation/tasks.py @@ -70,25 +70,26 @@ def add_annotations(data): from user.models import User item = Item.objects.get(itemId=data['item']) layer_id = data['layer'] - layer = filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers'])[0] + layer = filter(lambda l: l['id'] == layer_id, settings.CONFIG['layers']) + if not layer: + return False user = User.objects.get(username=data['user']) - with transaction.commit_on_success(): - for a in data['annotations']: - annotation = models.Annotation( - item=item, - layer=layer_id, - user=user, - start=float(a['in']), end=float(a['out']), - value=a['value']) - annotation.save() - #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() + for a in data['annotations']: + annotation = models.Annotation( + item=item, + layer=layer_id, + user=user, + start=float(a['in']), end=float(a['out']), + value=a['value']) + annotation.save() + #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() return True @task(ignore_results=True, queue='default')