Notification property has_been_read changed into unread
authorLennard de Rijk <ljvderijk@gmail.com>
Sat, 13 Dec 2008 14:55:00 +0000
changeset 737 4c78ee183eb6
parent 736 c70d56182ce2
child 738 61867ffea8a8
Notification property has_been_read changed into unread Due to comments on r1309. Patch By: Lennard de Rijk
app/soc/models/notification.py
app/soc/views/models/notification.py
--- a/app/soc/models/notification.py	Sat Dec 13 13:28:01 2008 +0000
+++ b/app/soc/models/notification.py	Sat Dec 13 14:55:00 2008 +0000
@@ -53,6 +53,6 @@
   created_on = db.DateTimeProperty(auto_now_add=True,
       verbose_name=ugettext_lazy('Created On'))
   
-  # boolean property that marks if the notification has been read
-  has_been_read = db.BooleanProperty(default=False,
-      verbose_name=ugettext_lazy('Read'))
+  # boolean property that marks if the notification is unread
+  unread = db.BooleanProperty(default=True,
+      verbose_name=ugettext_lazy('Unread'))
--- a/app/soc/views/models/notification.py	Sat Dec 13 13:28:01 2008 +0000
+++ b/app/soc/views/models/notification.py	Sat Dec 13 14:55:00 2008 +0000
@@ -63,7 +63,7 @@
     model = notification_model.Notification
 
     # exclude the necessary fields from the form
-    exclude = ['link_id', 'scope', 'scope_path', 'from_user', 'has_been_read']
+    exclude = ['link_id', 'scope', 'scope_path', 'from_user', 'unread']
 
   def clean_to_user(self):
     """Check if the to_user field has been filled in correctly.
@@ -185,13 +185,14 @@
 
     # if the user viewing is the user for which this notification is meant
     # and the notification has not been read yet
-    if not entity.has_been_read:
+    if entity.unread:
       # get the current user
       user = user_logic.logic.getForCurrentAccount()
-
+      
+      # if the message is meant for the user that is reading it
       if entity.scope.key() == user.key():
         # mark the entity as read
-        self._logic.updateModelProperties(entity, {'has_been_read' : True} )
+        self._logic.updateModelProperties(entity, {'unread' : False} )
 
     context['entity_type_url'] = self._params['url_name']
     context['entity_suffix'] = self._logic.getKeySuffix(entity)