Flush sidebar when creating a new entity
authorSverre Rabbelier <srabbelier@gmail.com>
Sat, 31 Jan 2009 12:59:52 +0000
changeset 1106 e14b0995cf29
parent 1105 326cd1181c03
child 1107 a878188e225c
Flush sidebar when creating a new entity Patch by: Sverre Rabbelier
app/soc/logic/models/base.py
app/soc/logic/models/document.py
app/soc/logic/models/group.py
app/soc/logic/models/notification.py
app/soc/logic/models/request.py
app/soc/logic/models/role.py
app/soc/logic/models/site.py
app/soc/logic/models/user.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.
--- 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()
--- 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()
--- 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.
--- 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()
--- 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()
--- 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()
--- 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()