#
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
@receiver([post_save, post_delete], sender=BookMedia)
def bookmedia_save(sender, instance, **kwargs):
+ instance.book.set_audio_length()
instance.book.save()
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()
@receiver(tags_updated)
def receive_tags_updated(sender, instance, affected_tags, **kwargs):
- categories = set(tag.category for tag in affected_tags
- if tag.category not in ('set', 'book'))
+ categories = set(tag.category for tag in affected_tags if tag.category not in ('set', 'book'))
if not categories:
return