1 # -*- coding: utf-8 -*-
2 from celery.task import task
3 from django.utils import translation
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)
11 cls._default_manager.get(pk=pk).refresh()
13 translation.activate(prev_language)
16 def refresh_instance(instance):
17 _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
20 @task(ignore_result=True)
21 def book_content_updated(book):
22 book.refresh_dc_cache()