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
--- 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()