X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ce8d791a5298e0cb2569034aec4c8b57afac97b2..91f30681b6687ac513f304a8827d1391236c00c3:/apps/catalogue/views.py diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index ef042de2..487307d5 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -19,6 +19,7 @@ from django.views.generic.simple import direct_to_template import librarian.html import librarian.text +from apiclient import NotAuthorizedError from catalogue import forms from catalogue import helpers from catalogue.helpers import active_tab @@ -294,8 +295,19 @@ def book(request, slug): else: form = None + try: + book.assert_publishable() + except AssertionError, e: + publishable = False + publishable_error = e + else: + publishable = True + publishable_error = None + return direct_to_template(request, "catalogue/book_detail.html", extra_context={ "book": book, + "publishable": publishable, + "publishable_error": publishable_error, "chunks": chunks, "need_fixing": need_fixing, "choose_master": choose_master, @@ -390,6 +402,8 @@ def publish(request, slug): book = get_object_or_404(Book, slug=slug) try: book.publish(request.user) + except NotAuthorizedError: + return http.HttpResponseRedirect(reverse('apiclient_oauth')) except BaseException, e: return http.HttpResponse(e) else: