# HG changeset patch # User Lennard de Rijk # Date 1232917392 0 # Node ID becede26c37fe5261b9ee2c3b2a35ee731e77949 # Parent fd1e6afb2d62c59cba43a7973a78037f499e8beb 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 diff -r fd1e6afb2d62 -r becede26c37f app/soc/logic/models/club.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() diff -r fd1e6afb2d62 -r becede26c37f app/soc/logic/models/group.py --- 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() diff -r fd1e6afb2d62 -r becede26c37f app/soc/logic/models/role.py --- 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()