+ access_time = datetime.now()
+ last_books = request.session.get("wiki_last_books", {})
+ last_books[reverse(editor, args=[chunk.book.slug, chunk.slug])] = {
+ 'time': mktime(access_time.timetuple()),
+ 'title': chunk.pretty_name(),
+ }
+
+ if len(last_books) > MAX_LAST_DOCS:
+ oldest_key = min(last_books, key=lambda x: last_books[x]['time'])
+ del last_books[oldest_key]
+ request.session['wiki_last_books'] = last_books
+
+ return render(request, template_name, {
+ 'chunk': chunk,
+ 'forms': {
+ "text_save": forms.DocumentTextSaveForm(user=request.user, prefix="textsave"),
+ "text_revert": forms.DocumentTextRevertForm(prefix="textrevert"),
+ "pubmark": forms.DocumentPubmarkForm(prefix="pubmark"),
+ },
+ 'can_pubmark': request.user.has_perm('catalogue.can_pubmark'),
+ 'REDMINE_URL': settings.REDMINE_URL,
+ })