@require_POST
@xframe_options_sameorigin
def del_image_async(request, image_id):
 user = request.user
 if (not user.is_authenticated()):
  message = _('You are not logged in.')
  return HttpResponseForbidden(json.dumps({'status': 'error', 'message': message}))
 try:
  image = ImageAttachment.objects.get(pk=image_id)
 except ImageAttachment.DoesNotExist:
  message = _('The requested image could not be found.')
  return HttpResponseNotFound(json.dumps({'status': 'error', 'message': message}))
 if (not ((user == image.creator) or user.has_perm('upload.delete_imageattachment'))):
  message = _('You do not have permission to do that.')
  return HttpResponseForbidden(json.dumps({'status': 'error', 'message': message}))
 image.file.delete()
 if image.thumbnail:
  image.thumbnail.delete()
 image.delete()
 return HttpResponse(json.dumps({'status': 'success'}))

@ require_POST @ xframe_options_sameorigin def del_image_async ( request , image_id ) : user = request . user if ( not user . is_authenticated ( ) ) : message = _ ( 'You are not logged in.' ) return HttpResponseForbidden ( json . dumps ( { 'status' : 'error' , 'message' : message } ) ) try : image = ImageAttachment . objects . get ( pk = image_id ) except ImageAttachment . DoesNotExist : message = _ ( 'The requested image could not be found.' ) return HttpResponseNotFound ( json . dumps ( { 'status' : 'error' , 'message' : message } ) ) if ( not ( ( user == image . creator ) or user . has_perm ( 'upload.delete_imageattachment' ) ) ) : message = _ ( 'You do not have permission to do that.' ) return HttpResponseForbidden ( json . dumps ( { 'status' : 'error' , 'message' : message } ) ) image . file . delete ( ) if image . thumbnail : image . thumbnail . delete ( ) image . delete ( ) return HttpResponse ( json . dumps ( { 'status' : 'success' } ) )
delete an image given its object id .