Skip to content

Instantly share code, notes, and snippets.

@anishmenon
Created June 1, 2014 18:30
Show Gist options
  • Save anishmenon/d3c601e0572cfb65dd73 to your computer and use it in GitHub Desktop.
Save anishmenon/d3c601e0572cfb65dd73 to your computer and use it in GitHub Desktop.
@login_required
def delete_videonote(request,id):
"""API: VideoNote delete"""
result = create_result()
v=VideoNote.objects.get(id=id)
form = VideoNoteDeleteApiForm(instance=v,request.POST or None)
if form.is_valid() and form.user==rquest.user:
try:
v.delete()
result['success'] = 1
result['result']['object'] = in_json(v)
except:
result['result'] = {'error_message': "This videonote isn't yours, so you are not allowed to delete this videonote."}
else:
result['result'] = {'errors': to_json_errors(form.errors.items())}
return api_response(request, result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment