Update cache on collection edit.
authorRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 30 Oct 2013 13:52:39 +0000 (14:52 +0100)
committerRadek Czajka <radekczajka@nowoczesnapolska.org.pl>
Wed, 30 Oct 2013 13:52:39 +0000 (14:52 +0100)
apps/catalogue/models/listeners.py

index 788957e..373a2fc 100644 (file)
@@ -40,6 +40,14 @@ def _pre_delete_handler(sender, instance, **kwargs):
 pre_delete.connect(_pre_delete_handler)
 
 
 pre_delete.connect(_pre_delete_handler)
 
 
+def _post_delete_handler(sender, instance, **kwargs):
+    """ refresh Book on BookMedia delete """
+    if sender == Collection:
+        permanent_cache.delete('catalogue.collection:%s' % instance.slug)
+        permanent_cache.delete('catalogue.catalogue')
+post_delete.connect(_post_delete_handler)
+
+
 def _post_save_handler(sender, instance, **kwargs):
     """ refresh all the short_html stuff on BookMedia update """
     if sender == BookMedia:
 def _post_save_handler(sender, instance, **kwargs):
     """ refresh all the short_html stuff on BookMedia update """
     if sender == BookMedia:
@@ -48,6 +56,7 @@ def _post_save_handler(sender, instance, **kwargs):
             'catalogue.audiobook_list', 'catalogue.daisy_list'])
     elif sender == Collection:
         permanent_cache.delete('catalogue.collection:%s' % instance.slug)
             'catalogue.audiobook_list', 'catalogue.daisy_list'])
     elif sender == Collection:
         permanent_cache.delete('catalogue.collection:%s' % instance.slug)
+        permanent_cache.delete('catalogue.catalogue')
 post_save.connect(_post_save_handler)
 
 
 post_save.connect(_post_save_handler)