Move checking membership to Membership.
[wolnelektury.git] / src / catalogue / signals.py
index 3adfedb..d3d6ec3 100644 (file)
@@ -1,9 +1,9 @@
-# -*- coding: utf-8 -*-
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from django.conf import settings
 from django.core.cache import caches
 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
 #
 from django.conf import settings
 from django.core.cache import caches
+from django.core.exceptions import ImproperlyConfigured
 from django.db.models.signals import post_save, post_delete
 from django.dispatch import receiver
 from ssify import flush_ssi_includes
 from django.db.models.signals import post_save, post_delete
 from django.dispatch import receiver
 from ssify import flush_ssi_includes
@@ -19,6 +19,7 @@ from .models import BookMedia, Book, Collection, Fragment, Tag
 
 @receiver([post_save, post_delete], sender=BookMedia)
 def bookmedia_save(sender, instance, **kwargs):
 
 @receiver([post_save, post_delete], sender=BookMedia)
 def bookmedia_save(sender, instance, **kwargs):
+    instance.book.set_audio_length()
     instance.book.save()
 
 
     instance.book.save()
 
 
@@ -50,6 +51,11 @@ def collection_delete(sender, instance, **kwargs):
 def book_save(sender, instance, **kwargs):
     # Books come out anywhere.
     caches[settings.CACHE_MIDDLEWARE_ALIAS].clear()
 def book_save(sender, instance, **kwargs):
     # Books come out anywhere.
     caches[settings.CACHE_MIDDLEWARE_ALIAS].clear()
+    # deleting selectively is too much work
+    try:
+        caches['template_fragments'].clear()
+    except ImproperlyConfigured:
+        pass
     instance.flush_includes()
 
 
     instance.flush_includes()