From: Aleksander Ɓukasz Date: Thu, 7 Aug 2014 10:24:08 +0000 (+0200) Subject: Editor fix - fix jumping to a different document version X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/72fcd14262e47075d7656c737d837c7a418f0d15?ds=sidebyside;hp=8cbcaefd6051029e67d2532c60780896dbf0b29f Editor fix - fix jumping to a different document version --- 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 }),