From a494a95bf89ed6aa55b5f14b71a343e33d55bd60 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 22 Aug 2012 11:23:02 +0200 Subject: [PATCH] No reason for 'ready for publish' check to be in celery, it's synchronous anyway. --- apps/catalogue/models/book.py | 8 ++++++++ apps/catalogue/tasks.py | 18 ------------------ apps/catalogue/views.py | 3 +-- lib/librarian | 2 +- 4 files changed, 10 insertions(+), 21 deletions(-) diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 25b9304e..772634c6 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -270,6 +270,14 @@ class Book(models.Model): valid_about = self.correct_about() assert bi.about == valid_about, _("rdf:about is not") + " " + valid_about + def publishable_error(self): + try: + return self.assert_publishable() + except AssertionError, e: + return e + else: + return None + def hidden(self): return self.slug.startswith('.') diff --git a/apps/catalogue/tasks.py b/apps/catalogue/tasks.py index ca696256..c386c22b 100644 --- a/apps/catalogue/tasks.py +++ b/apps/catalogue/tasks.py @@ -15,24 +15,6 @@ def refresh_instance(instance): _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language()) -@task -def _publishable_error(book, language=None): - prev_language = translation.get_language() - language and translation.activate(language) - try: - return book.assert_publishable() - except AssertionError, e: - return e - else: - return None - finally: - translation.activate(prev_language) - -def publishable_error(book): - return _publishable_error.delay(book, - translation.get_language()).wait() - - @task(ignore_result=True) def book_content_updated(book): book.refresh_dc_cache() diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 657a1257..74036f0d 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -26,7 +26,6 @@ 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 # # Quick hack around caching problems, TODO: use ETags @@ -303,7 +302,7 @@ def book(request, slug): 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={ diff --git a/lib/librarian b/lib/librarian index cbe81ee3..fb1bbfe6 160000 --- a/lib/librarian +++ b/lib/librarian @@ -1 +1 @@ -Subproject commit cbe81ee35b07783b4f52c3d3dda83db7aaf82d34 +Subproject commit fb1bbfe622abeaaea2a2dfc459d8b779b2d369a2 -- 2.20.1