trimming buttons on toolbar
[redakcja.git] / apps / catalogue / views.py
index fad8a69..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 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
 
 #
 from catalogue import xml_tools
 
 #
@@ -56,6 +57,8 @@ def my(request):
     return render(request, 'catalogue/my_page.html', {
         'last_books': sorted(request.session.get("wiki_last_books", {}).items(),
                         key=lambda x: x[1]['time'], reverse=True),
     return render(request, 'catalogue/my_page.html', {
         'last_books': sorted(request.session.get("wiki_last_books", {}).items(),
                         key=lambda x: x[1]['time'], reverse=True),
+
+        "logout_to": '/',
         })
 
 
         })
 
 
@@ -110,6 +113,8 @@ def create_missing(request, slug=None):
     return direct_to_template(request, "catalogue/document_create_missing.html", extra_context={
         "slug": slug,
         "form": form,
     return direct_to_template(request, "catalogue/document_create_missing.html", extra_context={
         "slug": slug,
         "form": form,
+
+        "logout_to": '/',
     })
 
 
     })
 
 
@@ -165,12 +170,16 @@ def upload(request):
                 "ok_list": ok_list,
                 "skipped_list": skipped_list,
                 "error_list": error_list,
                 "ok_list": ok_list,
                 "skipped_list": skipped_list,
                 "error_list": error_list,
+
+                "logout_to": '/',
             })
     else:
         form = forms.DocumentsUploadForm()
 
     return direct_to_template(request, "catalogue/document_upload.html", extra_context={
         "form": form,
             })
     else:
         form = forms.DocumentsUploadForm()
 
     return direct_to_template(request, "catalogue/document_upload.html", extra_context={
         "form": form,
+
+        "logout_to": '/',
     })
 
 
     })
 
 
@@ -232,20 +241,14 @@ def book(request, slug):
         form = forms.ReadonlyBookForm(instance=book)
         editable = False
 
         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,
 
     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,
     })
         "form": form,
         "editable": editable,
     })
@@ -326,6 +329,8 @@ def book_append(request, slug):
     return direct_to_template(request, "catalogue/book_append_to.html", extra_context={
         "book": book,
         "form": form,
     return direct_to_template(request, "catalogue/book_append_to.html", extra_context={
         "book": book,
         "form": form,
+
+        "logout_to": '/',
     })
 
 
     })