+@never_cache
+def history(request, chunk_id):
+ # TODO: pagination
+ doc = get_object_or_404(Chunk, pk=chunk_id)
+ if not doc.book.accessible(request):
+ return HttpResponseForbidden("Not authorized.")
+
+ changes = []
+ for change in doc.history().reverse():
+ changes.append({
+ "version": change.revision,
+ "description": change.description,
+ "author": change.author_str(),
+ "date": localize(change.created_at),
+ "publishable": _("Publishable") + "\n" if change.publishable else "",
+ "tag": ',\n'.join(unicode(tag) for tag in change.tags.all()),
+ "published": _("Published") + ": " + \
+ localize(change.publish_log.order_by('-book_record__timestamp')[0].book_record.timestamp) \
+ if change.publish_log.exists() else "",
+ })
+ return JSONResponse(changes)