fix argument types in build command
[redakcja.git] / apps / catalogue / tasks.py
1 # -*- coding: utf-8 -*-
2 #
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.
5 #
6 from celery.task import task
7 from django.utils import translation
8
9
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)
14     try:
15         cls._default_manager.get(pk=pk).refresh()
16     finally:
17         translation.activate(prev_language)
18
19
20 def refresh_instance(instance):
21     _refresh_by_pk.delay(type(instance), instance.pk, translation.get_language())
22
23
24 @task(ignore_result=True)
25 def book_content_updated(book):
26     book.refresh_dc_cache()