1 from celery.task import task
2 from django.utils import translation
3 from django.conf import settings
7 def _refresh_by_pk(cls, pk, language=None):
8 prev_language = translation.get_language()
9 language and translation.activate(language)
11 cls._default_manager.get(pk=pk).refresh()
13 translation.activate(prev_language)
15 def refresh_instance(instance):
16 _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
20 def _publishable_error(book, language=None):
21 prev_language = translation.get_language()
22 language and translation.activate(language)
24 return book.assert_publishable()
25 except AssertionError, e:
30 translation.activate(prev_language)
32 def publishable_error(book):
33 return _publishable_error.delay(book,
34 translation.get_language()).wait()