@handle_response_format
@treeio_login_required
def document_edit(request, document_id, response_format='html'):
 document = get_object_or_404(Document, pk=document_id)
 if (not request.user.profile.has_permission(document, mode='w')):
  return user_denied(request, message="You don't have access to this Document")
 if request.POST:
  if ('cancel' not in request.POST):
   form = DocumentForm(request.user.profile, None, request.POST, instance=document)
   if form.is_valid():
    document = form.save()
    return HttpResponseRedirect(reverse('documents_document_view', args=[document.id]))
  else:
   return HttpResponseRedirect(reverse('documents_document_view', args=[document.id]))
 else:
  form = DocumentForm(request.user.profile, None, instance=document)
 context = _get_default_context(request)
 context.update({'form': form, 'document': document})
 return render_to_response('documents/document_edit', context, context_instance=RequestContext(request), response_format=response_format)

@ handle_response_format @ treeio_login_required def document_edit ( request , document_id , response_format = 'html' ) : document = get_object_or_404 ( Document , pk = document_id ) if ( not request . user . profile . has_permission ( document , mode = 'w' ) ) : return user_denied ( request , message = "You don't have access to this Document" ) if request . POST : if ( 'cancel' not in request . POST ) : form = DocumentForm ( request . user . profile , None , request . POST , instance = document ) if form . is_valid ( ) : document = form . save ( ) return HttpResponseRedirect ( reverse ( 'documents_document_view' , args = [ document . id ] ) ) else : return HttpResponseRedirect ( reverse ( 'documents_document_view' , args = [ document . id ] ) ) else : form = DocumentForm ( request . user . profile , None , instance = document ) context = _get_default_context ( request ) context . update ( { 'form' : form , 'document' : document } ) return render_to_response ( 'documents/document_edit' , context , context_instance = RequestContext ( request ) , response_format = response_format )
document edit page .