From 70438cf6d3e003d68a99c769c40af1414b85e4a3 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Wed, 17 Jul 2013 11:41:43 +0000 Subject: [PATCH] order clips in transaction --- pandora/edit/models.py | 2 +- pandora/edit/views.py | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/pandora/edit/models.py b/pandora/edit/models.py index 7d51aedd4..b22608cbf 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -68,7 +68,7 @@ class Edit(models.Model): if clip.index == None: clip.index = 0 else: - clip.index +=1 + clip.index += 1 # dont add clip if in/out are invalid if not clip.annotation: duration = clip.item.sort.duration diff --git a/pandora/edit/views.py b/pandora/edit/views.py index a8c436845..936a99fec 100644 --- a/pandora/edit/views.py +++ b/pandora/edit/views.py @@ -8,6 +8,7 @@ import ox from ox.utils import json from ox.django.decorators import login_required_json from ox.django.shortcuts import render_to_json_response, get_object_or_404_json, json_response +from django.db import transaction from django.db.models import Max from ox.django.http import HttpFileResponse from ox.django.api import actions @@ -135,9 +136,10 @@ def orderClips(request): ids = map(ox.fromAZ, data['ids']) if edit.editable(request.user): index = 0 - for i in ids: - models.Clip.objects.filter(edit=edit, id=i).update(index=index) - index += 1 + with transaction.commit_on_success(): + for i in ids: + models.Clip.objects.filter(edit=edit, id=i).update(index=index) + index += 1 else: response = json_response(status=403, text='permission denied') return render_to_json_response(response)