from catalogue import helpers
from catalogue.helpers import active_tab
from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord
-from catalogue.tasks import publishable_error
#
# Quick hack around caching problems, TODO: use ETags
form = forms.ReadonlyBookForm(instance=book)
editable = False
- publish_error = publishable_error(book)
+ publish_error = book.publishable_error()
publishable = publish_error is None
return direct_to_template(request, "catalogue/book_detail.html", extra_context={
for c in chunks: c.user = user
+ status = request.POST.get('status')
+ if status:
+ books_affected = set()
+ for c in chunks:
+ if status == 'publish':
+ c.head.publishable = True
+ c.head.save()
+ elif status == 'unpublish':
+ c.head.publishable = False
+ c.head.save()
+ c.touch() # cache
+ books_affected.add(c.book)
+ for b in books_affected:
+ b.touch() # cache
+
for c in chunks: c.save()
return HttpResponse("", content_type="text/plain")