From 72fcd14262e47075d7656c737d837c7a418f0d15 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Thu, 7 Aug 2014 12:24:08 +0200 Subject: [PATCH] Editor fix - fix jumping to a different document version --- apps/wiki/static/wiki/editor | 2 +- apps/wiki/templates/wiki/bootstrap.html | 7 +++++++ apps/wiki/views.py | 12 ++++++++++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/apps/wiki/static/wiki/editor b/apps/wiki/static/wiki/editor index a892115b..a6919c02 160000 --- a/apps/wiki/static/wiki/editor +++ b/apps/wiki/static/wiki/editor @@ -1 +1 @@ -Subproject commit a892115bc1f94bfd53873dd442854b5ebe3fd03c +Subproject commit a6919c029590f1b93e156264b063f2a9bbcff8dc diff --git a/apps/wiki/templates/wiki/bootstrap.html b/apps/wiki/templates/wiki/bootstrap.html index 73e47cac..cbf0232a 100644 --- a/apps/wiki/templates/wiki/bootstrap.html +++ b/apps/wiki/templates/wiki/bootstrap.html @@ -338,6 +338,13 @@ documentAttachmentUrl: function(attachmentName) { return '{{MEDIA_URL}}{{IMAGE_DIR}}{{slug}}/' + attachmentName; }, + documentUrl: function(id, version) { + var url = '{% url 'wiki_editor' slug %}' + if(version) { + url = url + '?version=' + version; + } + return url; + }, documentSaveForm: { fields: [ diff --git a/apps/wiki/views.py b/apps/wiki/views.py index d7763025..7ecec635 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -83,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 }), -- 2.20.1