trimming buttons on toolbar
[redakcja.git] / apps / catalogue / views.py
index 72cf63d..6fb5f60 100644 (file)
@@ -27,6 +27,7 @@ from catalogue import forms
 from catalogue import helpers
 from catalogue.helpers import active_tab
 from catalogue.models import Book, Chunk, BookPublishRecord, ChunkPublishRecord
+from catalogue.tasks import publishable_error
 from catalogue import xml_tools
 
 #
@@ -240,20 +241,14 @@ def book(request, slug):
         form = forms.ReadonlyBookForm(instance=book)
         editable = False
 
-
-    try:
-        book.assert_publishable()
-    except AssertionError, e:
-        publishable = False
-        publishable_error = e
-    else:
-        publishable = True
-        publishable_error = None
+    task = publishable_error.delay(book)
+    publish_error = task.wait()
+    publishable = publish_error is None
 
     return direct_to_template(request, "catalogue/book_detail.html", extra_context={
         "book": book,
         "publishable": publishable,
-        "publishable_error": publishable_error,
+        "publishable_error": publish_error,
         "form": form,
         "editable": editable,
     })