forked from 0x2620/pandora
addClips: return error if item/in/out missing, not 500
This commit is contained in:
parent
819181726a
commit
3da3bd37fd
2 changed files with 5 additions and 3 deletions
|
@ -75,10 +75,12 @@ class Edit(models.Model):
|
||||||
if 'annotation' in data and data['annotation']:
|
if 'annotation' in data and data['annotation']:
|
||||||
c.annotation = Annotation.objects.get(public_id=data['annotation'])
|
c.annotation = Annotation.objects.get(public_id=data['annotation'])
|
||||||
c.item = c.annotation.item
|
c.item = c.annotation.item
|
||||||
else:
|
elif 'item' in data and 'in' in data and 'out' in data:
|
||||||
c.item = Item.objects.get(public_id=data['item'])
|
c.item = Item.objects.get(public_id=data['item'])
|
||||||
c.start = data['in']
|
c.start = data['in']
|
||||||
c.end = data['out']
|
c.end = data['out']
|
||||||
|
else:
|
||||||
|
return False
|
||||||
if index != None:
|
if index != None:
|
||||||
c.index = index
|
c.index = index
|
||||||
# dont add clip if in/out are invalid
|
# dont add clip if in/out are invalid
|
||||||
|
|
|
@ -55,7 +55,7 @@ def addClips(request, data):
|
||||||
if edit.editable(request.user):
|
if edit.editable(request.user):
|
||||||
clips = edit.add_clips(data['clips'], data.get('index'), request.user)
|
clips = edit.add_clips(data['clips'], data.get('index'), request.user)
|
||||||
if not clips:
|
if not clips:
|
||||||
response = json_response(status=500, text='invalid in/out')
|
response = json_response(status=500, text='invalid or missing item/in/out')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
add_changelog(request, data, edit.get_id())
|
add_changelog(request, data, edit.get_id())
|
||||||
response['data']['clips'] = clips
|
response['data']['clips'] = clips
|
||||||
|
@ -268,7 +268,7 @@ def addEdit(request, data):
|
||||||
if 'clips' in data and edit.type == 'static':
|
if 'clips' in data and edit.type == 'static':
|
||||||
clips = edit.add_clips(data['clips'], 0, request.user)
|
clips = edit.add_clips(data['clips'], 0, request.user)
|
||||||
if not clips:
|
if not clips:
|
||||||
response = json_response(status=500, text='invalid in/out')
|
response = json_response(status=500, text='invalid or missing item/in/out')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
||||||
if edit.status == 'featured':
|
if edit.status == 'featured':
|
||||||
|
|
Loading…
Reference in a new issue