3e23037960e91ded6b09dcc8834329e7ff072200
[redakcja.git] / apps / catalogue / tasks.py
1 from celery.task import task
2
3
4 @task
5 def refresh_by_pk(cls, pk):
6     cls._default_manager.get(pk=pk).refresh()
7
8
9 def refresh_instance(instance):
10     refresh_by_pk.delay(type(instance), instance.pk)
11
12
13 @task
14 def publishable_error(book):
15     try:
16         book.assert_publishable()
17     except AssertionError, e:
18         return e
19     else:
20        return None