cleanup css
[redakcja.git] / apps / catalogue / tasks.py
1 # -*- coding: utf-8 -*-
2 from celery.task import task
3 from django.utils import translation
4
5
6 @task(ignore_result=True)
7 def _refresh_by_pk(cls, pk, language=None):
8     prev_language = translation.get_language()
9     language and translation.activate(language)
10     try:
11         cls._default_manager.get(pk=pk).refresh()
12     finally:
13         translation.activate(prev_language)
14
15
16 def refresh_instance(instance):
17     _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
18
19
20 @task(ignore_result=True)
21 def book_content_updated(book):
22     book.refresh_dc_cache()