# HG changeset patch # User Sverre Rabbelier # Date 1233406792 0 # Node ID e14b0995cf293b47878dc0334bd721df0df8d245 # Parent 326cd1181c03fa028cc44ed8fa3cb26b09a5329f Flush sidebar when creating a new entity Patch by: Sverre Rabbelier diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/base.py --- a/app/soc/logic/models/base.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/base.py Sat Jan 31 12:59:52 2009 +0000 @@ -31,6 +31,7 @@ from django.utils.translation import ugettext +from soc.cache import sidebar from soc.logic import dicts from soc.views import out_of_band @@ -108,11 +109,11 @@ def _onCreate(self, entity): """Called when an entity has been created. - + Classes that override this can use it to do any post-creation operations. """ - - pass + + sidebar.flush() def _onUpdate(self, entity): """Called when an entity has been updated. diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/document.py --- a/app/soc/logic/models/document.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/document.py Sat Jan 31 12:59:52 2009 +0000 @@ -69,12 +69,5 @@ 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() diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/group.py --- a/app/soc/logic/models/group.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/group.py Sat Jan 31 12:59:52 2009 +0000 @@ -92,9 +92,5 @@ return True - def _onCreate(self, entity): - """Flushes the sidebar for the current user. - """ - sidebar.flush() logic = Logic() diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/notification.py --- a/app/soc/logic/models/notification.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/notification.py Sat Jan 31 12:59:52 2009 +0000 @@ -58,8 +58,7 @@ # there is only one unread notification so send out an email notifications.sendNewNotificationMessage(entity) - # flush the sidebar cache - sidebar.flush(entity.scope.account) + super(Logic, self)._onCreate(entity) def _updateField(self, entity, name, value): """If unread changes we flush the sidebar cache. diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/request.py --- a/app/soc/logic/models/request.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/request.py Sat Jan 31 12:59:52 2009 +0000 @@ -71,5 +71,7 @@ # TODO(Lennard) Create a new request message pass + super(Logic, self)._onCreate(entity) + logic = Logic() diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/role.py --- a/app/soc/logic/models/role.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/role.py Sat Jan 31 12:59:52 2009 +0000 @@ -81,5 +81,7 @@ if entity.status == 'active': sidebar.flush(entity.user.account) + super(View, self)._onCreate(entity) + logic = Logic() diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/site.py --- a/app/soc/logic/models/site.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/site.py Sat Jan 31 12:59:52 2009 +0000 @@ -80,11 +80,5 @@ """ return self.getFromFields(link_id=self.DEF_SITE_LINK_ID) - def _onCreate(self, entity): - """Flush the sidebar cache when a new active role entity has been created. - """ - - sidebar.flush() - logic = Logic() diff -r 326cd1181c03 -r e14b0995cf29 app/soc/logic/models/user.py --- a/app/soc/logic/models/user.py Sat Jan 31 12:36:07 2009 +0000 +++ b/app/soc/logic/models/user.py Sat Jan 31 12:59:52 2009 +0000 @@ -152,7 +152,8 @@ """ notifications.sendWelcomeMessage(entity) - sidebar.flush(entity.account) + + super(Logic, self)._onCreate(entity) logic = Logic()