properly update item after removing selected video

This commit is contained in:
j 2014-03-09 16:45:13 +00:00
parent 5429b0d6b5
commit d8e20d9380

View file

@ -456,11 +456,16 @@ def removeMedia(request):
response = json_response()
if request.user.get_profile().get_level() == 'admin':
qs = models.File.objects.filter(oshash__in=data['ids'], instances__id=None)
for f in qs:
if f.item.sort.numberoffiles:
f.item.sort.numberoffiles -= 1
f.item.sort.save()
selected = set([f.item.id for f in qs if f.selected])
items = list(set([f.item.id for f in qs]))
print selected
print items
qs.delete()
for i in Item.objects.filter(id__in=items):
if i.id in selected:
i.update_timeline()
else:
i.save()
else:
response = json_response(status=403, text='permissino denied')
return render_to_json_response(response)