- 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()
-
- if request.method == "POST":
- form = DocumentCreateForm(request.POST, request.FILES)
- if form.is_valid():
- doc = storage.create_document(
- id=form.cleaned_data['id'],
- text=form.cleaned_data['text'],
- )
-
- return http.HttpResponseRedirect(reverse("wiki_details", args=[doc.name]))
- else:
- form = DocumentCreateForm(initial={
- "id": name.replace(" ", "_"),
- "title": name.title(),
- })
-
- return direct_to_template(request, "wiki/document_create_missing.html", extra_context={
- "document_name": name,
- "form": form,
+ last_books = request.session.get("wiki_last_books", {})
+ last_books[slug, chunk.slug] = {
+ 'time': mktime(access_time.timetuple()),
+ 'title': chunk.book.title,
+ }
+
+ 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,
+ 'revision': revision,
+ 'readonly': True,
+ 'REDMINE_URL': settings.REDMINE_URL,