No reason for 'ready for publish' check to be in celery, it's synchronous anyway.
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 22 Aug 2012 09:23:02 +0000 (11:23 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 22 Aug 2012 09:23:02 +0000 (11:23 +0200)
apps/catalogue/models/book.py
apps/catalogue/tasks.py
apps/catalogue/views.py
lib/librarian

index 25b9304..772634c 100755 (executable)
@@ -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('.')
 
index ca69625..c386c22 100644 (file)
@@ -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()
index 657a125..74036f0 100644 (file)
@@ -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={
index cbe81ee..fb1bbfe 160000 (submodule)
@@ -1 +1 @@
-Subproject commit cbe81ee35b07783b4f52c3d3dda83db7aaf82d34
+Subproject commit fb1bbfe622abeaaea2a2dfc459d8b779b2d369a2