- 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': document.info,
- 'document_meta': document.meta,
+ last_books = request.session.get("wiki_last_books", {})
+ last_books[slug, chunk.slug] = {
+ 'time': access_time,
+ '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
+
+ save_form = forms.DocumentTextSaveForm(user=request.user, prefix="textsave")
+ return render(request, template_name, {
+ 'serialized_document_data': simplejson.dumps({
+ 'document': chunk.materialize(),
+ 'document_id': chunk.id,
+ 'title': chunk.book.title,
+ 'history': get_history(chunk),
+ 'version': chunk.revision(),
+ 'stage': chunk.stage.name if chunk.stage else None,
+ 'assignment': chunk.user.username if chunk.user else None
+ }),
+ 'serialized_templates': simplejson.dumps([
+ {'id': t.id, 'name': t.name, 'content': t.content} for t in Template.objects.filter(is_partial=True)
+ ]),