@handle_response_format
@treeio_login_required
def file_delete(request, file_id, response_format='html'):
 file = get_object_or_404(File, pk=file_id)
 if (not request.user.profile.has_permission(file, mode='w')):
  return user_denied(request, message="You don't have access to this File")
 if request.POST:
  if ('delete' in request.POST):
   if ('trash' in request.POST):
    file.trash = True
    file.save()
   else:
    file.delete()
   return HttpResponseRedirect(reverse('document_index'))
  elif ('cancel' in request.POST):
   return HttpResponseRedirect(reverse('documents_file_view', args=[file.id]))
 context = _get_default_context(request)
 context.update({'file': file})
 return render_to_response('documents/file_delete', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def file_delete ( request , file_id , response_format = 'html' ) : file = get_object_or_404 ( File , pk = file_id ) if ( not request . user . profile . has_permission ( file , mode = 'w' ) ) : return user_denied ( request , message = "You don't have access to this File" ) if request . POST : if ( 'delete' in request . POST ) : if ( 'trash' in request . POST ) : file . trash = True file . save ( ) else : file . delete ( ) return HttpResponseRedirect ( reverse ( 'document_index' ) ) elif ( 'cancel' in request . POST ) : return HttpResponseRedirect ( reverse ( 'documents_file_view' , args = [ file . id ] ) ) context = _get_default_context ( request ) context . update ( { 'file' : file } ) return render_to_response ( 'documents/file_delete' , context , context_instance = RequestContext ( request ) , response_format = response_format )
file delete .