# HG changeset patch # User Sverre Rabbelier # Date 1233102911 0 # Node ID 0cd056f2c7399b337ade645b00833a628b6d77e3 # Parent 02ffb446da6e250aeab6bd7e83e69bd6c9eedfda Flush cache if user makes a document featured Also flush it if a new document is created as featured. Patch by: Sverre Rabbelier diff -r 02ffb446da6e -r 0cd056f2c739 app/soc/logic/models/document.py --- a/app/soc/logic/models/document.py Wed Jan 28 00:33:47 2009 +0000 +++ b/app/soc/logic/models/document.py Wed Jan 28 00:35:11 2009 +0000 @@ -22,6 +22,7 @@ ] +from soc.cache import sidebar from soc.logic.models import work from soc.logic.models import linkable as linkable_logic @@ -41,5 +42,21 @@ super(Logic, self).__init__(model=model, base_model=base_model, scope_logic=scope_logic) + def _updateField(self, entity, name, value): + """Special logic for role. If state changes to active we flush the sidebar. + """ + + if (name == 'is_featured') and (entity.is_featured != value): + sidebar.flush() + + return True + + def _onCreate(self, entity): + """Flush the sidebar cache when a new active role entity has been created. + """ + + if entity.is_featured: + sidebar.flush() + logic = Logic()