@handle_response_format
@treeio_login_required
def file_edit(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 ('cancel' not in request.POST):
   form = FileForm(request.user.profile, None, request.POST, request.FILES, instance=file)
   if form.is_valid():
    file = form.save()
    return HttpResponseRedirect(reverse('documents_file_view', args=[file.id]))
  else:
   return HttpResponseRedirect(reverse('documents_file_view', args=[file.id]))
 else:
  form = FileForm(request.user.profile, None, instance=file)
 context = _get_default_context(request)
 context.update({'form': form, 'file': file})
 return render_to_response('documents/file_edit', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def file_edit ( 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 ( 'cancel' not in request . POST ) : form = FileForm ( request . user . profile , None , request . POST , request . FILES , instance = file ) if form . is_valid ( ) : file = form . save ( ) return HttpResponseRedirect ( reverse ( 'documents_file_view' , args = [ file . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'documents_file_view' , args = [ file . id ] ) ) else : form = FileForm ( request . user . profile , None , instance = file ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'file' : file } ) return render_to_response ( 'documents/file_edit' , context , context_instance = RequestContext ( request ) , response_format = response_format )
file edit page .