use attr instead of data
[redakcja.git] / apps / catalogue / tasks.py
1 from celery.task import task
2 from django.utils import translation
3
4
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)
9     try:
10         cls._default_manager.get(pk=pk).refresh()
11     finally:
12         translation.activate(prev_language)
13
14 def refresh_instance(instance):
15     _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
16
17
18 @task(ignore_result=True)
19 def book_content_updated(book):
20     book.refresh_dc_cache()