Added cache flush for the user who creates a group and the user whose role has been activated.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 25 Jan 2009 21:03:12 +0000
changeset 991 becede26c37f
parent 990 fd1e6afb2d62
child 992 e9f7d8e96b20
Added cache flush for the user who creates a group and the user whose role has been activated. As requested by Sverre Rabbelier. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/logic/models/club.py
app/soc/logic/models/group.py
app/soc/logic/models/role.py
--- a/app/soc/logic/models/club.py	Sun Jan 25 16:50:24 2009 +0000
+++ b/app/soc/logic/models/club.py	Sun Jan 25 21:03:12 2009 +0000
@@ -69,5 +69,7 @@
       fields = {'status' : 'completed'}
       club_app_logic.logic.updateEntityProperties(application, fields)
 
+    super(Logic, self)._onCreate(entity)
+
 
 logic = Logic()
--- a/app/soc/logic/models/group.py	Sun Jan 25 16:50:24 2009 +0000
+++ b/app/soc/logic/models/group.py	Sun Jan 25 21:03:12 2009 +0000
@@ -22,6 +22,7 @@
   ]
 
 
+from soc.cache import sidebar
 from soc.logic.models import base
 
 import soc.models.group
@@ -91,5 +92,9 @@
 
     return True
 
+  def _onCreate(self, entity):
+    """Flushes the sidebar for the current user.
+    """
+    sidebar.flush()
 
 logic = Logic()
--- a/app/soc/logic/models/role.py	Sun Jan 25 16:50:24 2009 +0000
+++ b/app/soc/logic/models/role.py	Sun Jan 25 21:03:12 2009 +0000
@@ -23,6 +23,7 @@
   ]
 
 
+from soc.cache import sidebar
 from soc.logic.models import base
 
 import soc.models.role
@@ -62,5 +63,16 @@
 
     return group
 
+  def _updateField(self, entity, name, value):
+    """Special logic for role. If state changes to active we flush the sidebar.
+    """
+
+    if (name == 'state') and (entity.state != value) and value == 'active':
+      # in case the state of the role changes to active we flush the sidebar
+      # cache. Other changes will be visible after the retention time expires.
+      sidebar.flush(entity.user.account)
+
+    return True
+
 
 logic = Logic()