diff rhodecode/model/notification.py @ 2610:3fdf7c3be2c9 beta

added mark as read for single notifications
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 15 Jul 2012 04:02:58 +0200
parents 17893d61792a
children 493646d3146f
line wrap: on
line diff
--- a/rhodecode/model/notification.py	Sun Jul 15 03:15:43 2012 +0200
+++ b/rhodecode/model/notification.py	Sun Jul 15 04:02:58 2012 +0200
@@ -156,6 +156,23 @@
 
         return q.all()
 
+    def mark_read(self, user, notification):
+        try:
+            notification = self.__get_notification(notification)
+            user = self._get_user(user)
+            if notification and user:
+                obj = UserNotification.query()\
+                        .filter(UserNotification.user == user)\
+                        .filter(UserNotification.notification
+                                == notification)\
+                        .one()
+                obj.read = True
+                self.sa.add(obj)
+                return True
+        except Exception:
+            log.error(traceback.format_exc())
+            raise
+
     def mark_all_read_for_user(self, user, filter_=None):
         user = self._get_user(user)
         q = UserNotification.query()\