X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/75957f735219259d3b4bc361f80ccd3d7b92a0e9..59947fddf28d67c6822267c8a0fc28e13a6e9175:/src/catalogue/signals.py?ds=inline diff --git a/src/catalogue/signals.py b/src/catalogue/signals.py index 72f8a8910..8bbc0bf8f 100644 --- a/src/catalogue/signals.py +++ b/src/catalogue/signals.py @@ -1,5 +1,5 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from django.conf import settings from django.core.cache import caches @@ -7,7 +7,6 @@ from django.core.exceptions import ImproperlyConfigured from django.db.models.signals import post_save, post_delete from django.dispatch import receiver from newtagging.models import tags_updated -from picture.models import Picture, PictureArea from .models import BookMedia, Book, Collection, Fragment, Tag @@ -53,13 +52,6 @@ def book_save(sender, instance, **kwargs): def book_delete(sender, instance, **kwargs): caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() - if not settings.NO_SEARCH_INDEX: - # remove the book from search index, when it is deleted. - from search.index import Index - idx = Index() - idx.remove_book(instance) - idx.index_tags() - #### # Tag @@ -70,14 +62,8 @@ def book_delete(sender, instance, **kwargs): def tag_after_change(sender, instance, **kwargs): caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() - for model in Book, Picture: - for model_instance in model.tagged.with_all([instance]).only('pk'): - model_instance.clear_cache() - - if instance.category == 'author': - for model in Fragment, PictureArea: - for model_instance in model.tagged.with_all([instance]).only('pk'): - model_instance.clear_cache() + for book in Book.tagged.with_all([instance]).only('pk'): + book.clear_cache() @receiver(tags_updated) @@ -87,4 +73,5 @@ def receive_tags_updated(sender, instance, affected_tags, **kwargs): return caches[settings.CACHE_MIDDLEWARE_ALIAS].clear() - instance.clear_cache() + if sender in (Book,): + instance.clear_cache()