1 from celery.task import task
2 from django.utils import translation
5 @task(ignore_result=True)
6 def _refresh_by_pk(cls, pk, language=None):
7 prev_language = translation.get_language()
8 language and translation.activate(language)
10 cls._default_manager.get(pk=pk).refresh()
12 translation.activate(prev_language)
14 def refresh_instance(instance):
15 _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
19 def _publishable_error(book, language=None):
20 prev_language = translation.get_language()
21 language and translation.activate(language)
23 return book.assert_publishable()
24 except AssertionError, e:
29 translation.activate(prev_language)
31 def publishable_error(book):
32 return _publishable_error.delay(book,
33 translation.get_language()).wait()
36 @task(ignore_result=True)
37 def book_content_updated(book):
38 book.refresh_dc_cache()