Added flushing the sidebar when dealing with notifications.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 25 Jan 2009 23:35:39 +0000
changeset 997 d4ba019f1f8b
parent 996 a6f67d4c297f
child 998 125257161908
Added flushing the sidebar when dealing with notifications. On request from Pawel Solyga. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed
app/soc/logic/models/notification.py
--- a/app/soc/logic/models/notification.py	Sun Jan 25 22:42:09 2009 +0000
+++ b/app/soc/logic/models/notification.py	Sun Jan 25 23:35:39 2009 +0000
@@ -24,6 +24,7 @@
 
 from google.appengine.ext import db
 
+from soc.cache import sidebar
 from soc.logic.helper import notifications
 from soc.logic.models import base
 from soc.logic.models import user as user_logic
@@ -57,5 +58,18 @@
       # there is only one unread notification so send out an email
       notifications.sendNewNotificationMessage(entity)
 
+    # flush the sidebar cache
+    sidebar.flush(entity.scope.account)
+
+  def _updateField(self, entity, name, value):
+    """If unread changes we flush the sidebar cache.
+    """
+
+    if (name == 'unread') and (entity.unread != value):
+      # in case that the unread value changes we flush the sidebar.
+      sidebar.flush(entity.scope.account)
+
+    return True
+
 
 logic = Logic()