@block_user_agents
@login_required
@check_readonly
def revert_document(request, document_path, revision_id):
 (document_locale, document_slug, needs_redirect) = locale_and_slug_from_path(document_path, request)
 revision = get_object_or_404(Revision.objects.select_related('document'), pk=revision_id, document__slug=document_slug)
 if (not revision.document.allows_revision_by(request.user)):
  raise PermissionDenied
 if (request.method == 'GET'):
  return render(request, 'wiki/confirm_revision_revert.html', {'revision': revision, 'document': revision.document})
 else:
  comment = request.POST.get('comment')
  document = revision.document
  old_revision_pk = revision.pk
  try:
   new_revision = document.revert(revision, request.user, comment)
   if (new_revision.pk != old_revision_pk):
    document.schedule_rendering('max-age=0')
  except IntegrityError:
   return render(request, 'wiki/confirm_revision_revert.html', {'revision': revision, 'document': revision.document, 'error': ugettext('Document already exists. Note: You cannot revert a document that has been moved until you delete its redirect.')})
  return redirect('wiki.document_revisions', revision.document.slug)

@ block_user_agents @ login_required @ check_readonly def revert_document ( request , document_path , revision_id ) : ( document_locale , document_slug , needs_redirect ) = locale_and_slug_from_path ( document_path , request ) revision = get_object_or_404 ( Revision . objects . select_related ( 'document' ) , pk = revision_id , document__slug = document_slug ) if ( not revision . document . allows_revision_by ( request . user ) ) : raise PermissionDenied if ( request . method == 'GET' ) : return render ( request , 'wiki/confirm_revision_revert.html' , { 'revision' : revision , 'document' : revision . document } ) else : comment = request . POST . get ( 'comment' ) document = revision . document old_revision_pk = revision . pk try : new_revision = document . revert ( revision , request . user , comment ) if ( new_revision . pk != old_revision_pk ) : document . schedule_rendering ( 'max-age=0' ) except IntegrityError : return render ( request , 'wiki/confirm_revision_revert.html' , { 'revision' : revision , 'document' : revision . document , 'error' : ugettext ( 'Document already exists. Note: You cannot revert a document that has been moved until you delete its redirect.' ) } ) return redirect ( 'wiki.document_revisions' , revision . document . slug )
revert document to a specific revision .