X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/2cd5a971d3cf9708b43a523a339212cb9220cef3..82c38a77943cf91a084429bf10740edffbd0c195:/apps/wiki/views.py?ds=sidebyside diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 827a4838..7ecec635 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -15,6 +15,7 @@ from django.utils.translation import ugettext as _ from django.views.decorators.http import require_POST, require_GET from django.shortcuts import get_object_or_404, render from django.utils import simplejson +from django.contrib.auth.decorators import login_required from catalogue.models import Book, Chunk, Template import nice_diff @@ -51,6 +52,7 @@ def get_history(chunk): @never_cache +@login_required def editor(request, slug, chunk=None, template_name='wiki/bootstrap.html'): try: chunk = Chunk.get(slug, chunk) @@ -81,13 +83,21 @@ def editor(request, slug, chunk=None, template_name='wiki/bootstrap.html'): request.session['wiki_last_books'] = last_books save_form = forms.DocumentTextSaveForm(user=request.user, prefix="textsave") + try: + version = int(request.GET.get('version', None)) + except: + version = None + if version: + text = chunk.at_revision(version).materialize() + else: + text = chunk.materialize() return render(request, template_name, { 'serialized_document_data': simplejson.dumps({ - 'document': chunk.materialize(), + 'document': text, 'document_id': chunk.id, 'title': chunk.book.title, 'history': get_history(chunk), - 'version': chunk.revision(), + 'version': version or chunk.revision(), 'stage': chunk.stage.name if chunk.stage else None, 'assignment': chunk.user.username if chunk.user else None }),