From 4904b56b13182e75acfe943a6743941c8f26fa41 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Thu, 6 Aug 2015 12:42:32 +0100 Subject: [PATCH 1/2] addClips: return error if item/in/out missing, not 500 --- pandora/edit/models.py | 4 +++- pandora/edit/views.py | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pandora/edit/models.py b/pandora/edit/models.py index ad33d43..05d9709 100644 --- a/pandora/edit/models.py +++ b/pandora/edit/models.py @@ -75,10 +75,12 @@ class Edit(models.Model): if 'annotation' in data and data['annotation']: c.annotation = Annotation.objects.get(public_id=data['annotation']) 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.start = data['in'] c.end = data['out'] + else: + return False if index != None: c.index = index # dont add clip if in/out are invalid diff --git a/pandora/edit/views.py b/pandora/edit/views.py index 6e49f7e..1a41770 100644 --- a/pandora/edit/views.py +++ b/pandora/edit/views.py @@ -55,7 +55,7 @@ def addClips(request, data): if edit.editable(request.user): clips = edit.add_clips(data['clips'], data.get('index'), request.user) 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) add_changelog(request, data, edit.get_id()) response['data']['clips'] = clips @@ -268,7 +268,7 @@ def addEdit(request, data): if 'clips' in data and edit.type == 'static': clips = edit.add_clips(data['clips'], 0, request.user) 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) if edit.status == 'featured': -- 2.4.3