From: Radek Czajka Date: Wed, 30 Oct 2013 13:52:39 +0000 (+0100) Subject: Update cache on collection edit. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/32d67bcd63571d61f090b613aba48ec4c710ae1a?ds=sidebyside;hp=--cc Update cache on collection edit. --- 32d67bcd63571d61f090b613aba48ec4c710ae1a diff --git a/apps/catalogue/models/listeners.py b/apps/catalogue/models/listeners.py index 788957e14..373a2fcc8 100644 --- a/apps/catalogue/models/listeners.py +++ b/apps/catalogue/models/listeners.py @@ -40,6 +40,14 @@ def _pre_delete_handler(sender, instance, **kwargs): 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: @@ -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) + permanent_cache.delete('catalogue.catalogue') post_save.connect(_post_save_handler)