forked from 0x2620/pandora
dont use transaction for annotation import, fixes #2356
This commit is contained in:
parent
ad89e9ffed
commit
7ef70a04e0
1 changed files with 19 additions and 18 deletions
|
@ -70,25 +70,26 @@ def add_annotations(data):
|
||||||
from user.models import User
|
from user.models import User
|
||||||
item = Item.objects.get(itemId=data['item'])
|
item = Item.objects.get(itemId=data['item'])
|
||||||
layer_id = data['layer']
|
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'])
|
user = User.objects.get(username=data['user'])
|
||||||
with transaction.commit_on_success():
|
for a in data['annotations']:
|
||||||
for a in data['annotations']:
|
annotation = models.Annotation(
|
||||||
annotation = models.Annotation(
|
item=item,
|
||||||
item=item,
|
layer=layer_id,
|
||||||
layer=layer_id,
|
user=user,
|
||||||
user=user,
|
start=float(a['in']), end=float(a['out']),
|
||||||
start=float(a['in']), end=float(a['out']),
|
value=a['value'])
|
||||||
value=a['value'])
|
annotation.save()
|
||||||
annotation.save()
|
#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)
|
||||||
Item.objects.filter(id=item.id).update(modified=annotation.modified)
|
annotation.item.modified = annotation.modified
|
||||||
annotation.item.modified = annotation.modified
|
annotation.item.update_find()
|
||||||
annotation.item.update_find()
|
annotation.item.update_sort()
|
||||||
annotation.item.update_sort()
|
annotation.item.update_facets()
|
||||||
annotation.item.update_facets()
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@task(ignore_results=True, queue='default')
|
@task(ignore_results=True, queue='default')
|
||||||
|
|
Loading…
Reference in a new issue