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()
10 translation.activate(language)
12 cls._default_manager.get(pk=pk).refresh()
13 except cls.DoesNotExist:
16 translation.activate(prev_language)
19 def refresh_instance(instance):
20 _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
23 @task(ignore_result=True)
24 def book_content_updated(book):
25 book.refresh_dc_cache()