Mercurial > kallithea
comparison 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 |
comparison
equal
deleted
inserted
replaced
2609:200a5b747e69 | 2610:3fdf7c3be2c9 |
---|---|
154 if filter_: | 154 if filter_: |
155 q = q.filter(Notification.type_.in_(filter_)) | 155 q = q.filter(Notification.type_.in_(filter_)) |
156 | 156 |
157 return q.all() | 157 return q.all() |
158 | 158 |
159 def mark_read(self, user, notification): | |
160 try: | |
161 notification = self.__get_notification(notification) | |
162 user = self._get_user(user) | |
163 if notification and user: | |
164 obj = UserNotification.query()\ | |
165 .filter(UserNotification.user == user)\ | |
166 .filter(UserNotification.notification | |
167 == notification)\ | |
168 .one() | |
169 obj.read = True | |
170 self.sa.add(obj) | |
171 return True | |
172 except Exception: | |
173 log.error(traceback.format_exc()) | |
174 raise | |
175 | |
159 def mark_all_read_for_user(self, user, filter_=None): | 176 def mark_all_read_for_user(self, user, filter_=None): |
160 user = self._get_user(user) | 177 user = self._get_user(user) |
161 q = UserNotification.query()\ | 178 q = UserNotification.query()\ |
162 .filter(UserNotification.user == user)\ | 179 .filter(UserNotification.user == user)\ |
163 .filter(UserNotification.read == False)\ | 180 .filter(UserNotification.read == False)\ |