@login_required
def delete_revision(request, document_slug, revision_id):
 revision = get_object_or_404(Revision, pk=revision_id, document__slug=document_slug)
 document = revision.document
 if (not document.allows(request.user, 'delete_revision')):
  raise PermissionDenied
 only_revision = (document.revisions.count() == 1)
 helpful_votes = HelpfulVote.objects.filter(revision=revision.id)
 has_votes = helpful_votes.exists()
 if (request.method == 'GET'):
  return render(request, 'wiki/confirm_revision_delete.html', {'revision': revision, 'document': document, 'only_revision': only_revision, 'has_votes': has_votes})
 if only_revision:
  return HttpResponseBadRequest()
 log.warning(('User %s is deleting revision with id=%s' % (request.user, revision.id)))
 revision.delete()
 return HttpResponseRedirect(reverse('wiki.document_revisions', args=[document.slug]))

@ login_required def delete_revision ( request , document_slug , revision_id ) : revision = get_object_or_404 ( Revision , pk = revision_id , document__slug = document_slug ) document = revision . document if ( not document . allows ( request . user , 'delete_revision' ) ) : raise PermissionDenied only_revision = ( document . revisions . count ( ) == 1 ) helpful_votes = HelpfulVote . objects . filter ( revision = revision . id ) has_votes = helpful_votes . exists ( ) if ( request . method == 'GET' ) : return render ( request , 'wiki/confirm_revision_delete.html' , { 'revision' : revision , 'document' : document , 'only_revision' : only_revision , 'has_votes' : has_votes } ) if only_revision : return HttpResponseBadRequest ( ) log . warning ( ( 'User %s is deleting revision with id=%s' % ( request . user , revision . id ) ) ) revision . delete ( ) return HttpResponseRedirect ( reverse ( 'wiki.document_revisions' , args = [ document . slug ] ) )
delete a revision .