forked from 0x2620/pandora
order clips in transaction
This commit is contained in:
parent
49f211bfd8
commit
70438cf6d3
2 changed files with 6 additions and 4 deletions
|
@ -68,7 +68,7 @@ class Edit(models.Model):
|
||||||
if clip.index == None:
|
if clip.index == None:
|
||||||
clip.index = 0
|
clip.index = 0
|
||||||
else:
|
else:
|
||||||
clip.index +=1
|
clip.index += 1
|
||||||
# dont add clip if in/out are invalid
|
# dont add clip if in/out are invalid
|
||||||
if not clip.annotation:
|
if not clip.annotation:
|
||||||
duration = clip.item.sort.duration
|
duration = clip.item.sort.duration
|
||||||
|
|
|
@ -8,6 +8,7 @@ import ox
|
||||||
from ox.utils import json
|
from ox.utils import json
|
||||||
from ox.django.decorators import login_required_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 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 django.db.models import Max
|
||||||
from ox.django.http import HttpFileResponse
|
from ox.django.http import HttpFileResponse
|
||||||
from ox.django.api import actions
|
from ox.django.api import actions
|
||||||
|
@ -135,9 +136,10 @@ def orderClips(request):
|
||||||
ids = map(ox.fromAZ, data['ids'])
|
ids = map(ox.fromAZ, data['ids'])
|
||||||
if edit.editable(request.user):
|
if edit.editable(request.user):
|
||||||
index = 0
|
index = 0
|
||||||
for i in ids:
|
with transaction.commit_on_success():
|
||||||
models.Clip.objects.filter(edit=edit, id=i).update(index=index)
|
for i in ids:
|
||||||
index += 1
|
models.Clip.objects.filter(edit=edit, id=i).update(index=index)
|
||||||
|
index += 1
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='permission denied')
|
response = json_response(status=403, text='permission denied')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
Loading…
Reference in a new issue