X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/d64a8451dafc98e8f71455a55d123d22f3368ef9..f938afb8ab4cb091d12e0ef0311eaea14b774798:/apps/wiki/views.py?ds=sidebyside diff --git a/apps/wiki/views.py b/apps/wiki/views.py index 9b7d8076..46f0665f 100644 --- a/apps/wiki/views.py +++ b/apps/wiki/views.py @@ -3,7 +3,7 @@ import os from django.conf import settings from django.views.generic.simple import direct_to_template -from django.views.decorators.http import require_POST +from django.views.decorators.http import require_POST, require_GET from django.core.urlresolvers import reverse from wiki.helpers import JSONResponse, JSONFormInvalid, JSONServerError, ajax_require_permission from django import http @@ -70,6 +70,33 @@ def document_detail(request, name, template_name='wiki/document_details.html'): }) +@require_GET +def document_detail_readonly(request, name, template_name='wiki/document_details_readonly.html'): + storage = getstorage() + + try: + revision = request.GET['revision'] + document = storage.get(name, revision) + except (KeyError, DocumentNotFound) as e: + raise http.Http404 + + access_time = datetime.now() + last_documents = request.session.get("wiki_last_docs", {}) + last_documents[name] = access_time + + if len(last_documents) > MAX_LAST_DOCS: + oldest_key = min(last_documents, key=last_documents.__getitem__) + del last_documents[oldest_key] + request.session['wiki_last_docs'] = last_documents + + return direct_to_template(request, template_name, extra_context={ + 'document': document, + 'document_name': document.name, + 'document_info': dict(document.info(), readonly=True), + 'document_meta': document.meta, + }) + + def document_create_missing(request, name): storage = getstorage()