1 # -*- coding: utf-8 -*-
3 # This file is part of MIL/PEER, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
6 from celery.task import task
7 from django.utils import translation
10 @task(ignore_result=True)
11 def _refresh_by_pk(cls, pk, language=None):
12 prev_language = translation.get_language()
13 language and translation.activate(language)
15 cls._default_manager.get(pk=pk).refresh()
17 translation.activate(prev_language)
20 def refresh_instance(instance):
21 _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
24 @task(ignore_result=True)
25 def book_content_updated(book):
26 book.refresh_dc_cache()