@login_required
@require_POST
def cancel_draft(request, media_type='image'):
 drafts = _get_drafts(request.user)
 if ((media_type == 'image') and drafts['image']):
  drafts['image'].delete()
  drafts['image'] = None
 else:
  msg = _(u'Unrecognized request or nothing to cancel.')
  content_type = None
  if request.is_ajax():
   msg = json.dumps({'status': 'error', 'message': msg})
   content_type = 'application/json'
  return HttpResponseBadRequest(msg, content_type=content_type)
 if request.is_ajax():
  return HttpResponse(json.dumps({'status': 'success'}), content_type='application/json')
 return HttpResponseRedirect(reverse('gallery.gallery', args=[media_type]))

@ login_required @ require_POST def cancel_draft ( request , media_type = 'image' ) : drafts = _get_drafts ( request . user ) if ( ( media_type == 'image' ) and drafts [ 'image' ] ) : drafts [ 'image' ] . delete ( ) drafts [ 'image' ] = None else : msg = _ ( u'Unrecognized request or nothing to cancel.' ) content_type = None if request . is_ajax ( ) : msg = json . dumps ( { 'status' : 'error' , 'message' : msg } ) content_type = 'application/json' return HttpResponseBadRequest ( msg , content_type = content_type ) if request . is_ajax ( ) : return HttpResponse ( json . dumps ( { 'status' : 'success' } ) , content_type = 'application/json' ) return HttpResponseRedirect ( reverse ( 'gallery.gallery' , args = [ media_type ] ) )
delete an existing draft for the user .