Mercurial > kallithea
comparison rhodecode/controllers/admin/notifications.py @ 1791:2aee0dc1784e beta
mark all read button for notifications
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 19 Dec 2011 02:31:22 +0200 |
parents | 4a5b93b3bcdd |
children | cf51bbfb120e |
comparison
equal
deleted
inserted
replaced
1790:f551007ce085 | 1791:2aee0dc1784e |
---|---|
1 import logging | 1 import logging |
2 import traceback | 2 import traceback |
3 | 3 |
4 from pylons import request | |
4 from pylons import tmpl_context as c, url | 5 from pylons import tmpl_context as c, url |
5 from pylons.controllers.util import redirect | 6 from pylons.controllers.util import redirect |
6 | 7 |
7 from rhodecode.lib.base import BaseController, render | 8 from rhodecode.lib.base import BaseController, render |
8 from rhodecode.model.db import Notification | 9 from rhodecode.model.db import Notification |
13 from rhodecode.model.meta import Session | 14 from rhodecode.model.meta import Session |
14 | 15 |
15 | 16 |
16 log = logging.getLogger(__name__) | 17 log = logging.getLogger(__name__) |
17 | 18 |
19 | |
18 class NotificationsController(BaseController): | 20 class NotificationsController(BaseController): |
19 """REST Controller styled on the Atom Publishing Protocol""" | 21 """REST Controller styled on the Atom Publishing Protocol""" |
20 # To properly map this controller, ensure your config/routing.py | 22 # To properly map this controller, ensure your config/routing.py |
21 # file has a resource setup: | 23 # file has a resource setup: |
22 # map.resource('notification', 'notifications', controller='_admin/notifications', | 24 # map.resource('notification', 'notifications', controller='_admin/notifications', |
25 @LoginRequired() | 27 @LoginRequired() |
26 @NotAnonymous() | 28 @NotAnonymous() |
27 def __before__(self): | 29 def __before__(self): |
28 super(NotificationsController, self).__before__() | 30 super(NotificationsController, self).__before__() |
29 | 31 |
30 | |
31 def index(self, format='html'): | 32 def index(self, format='html'): |
32 """GET /_admin/notifications: All items in the collection""" | 33 """GET /_admin/notifications: All items in the collection""" |
33 # url('notifications') | 34 # url('notifications') |
34 c.user = self.rhodecode_user | 35 c.user = self.rhodecode_user |
35 c.notifications = NotificationModel()\ | 36 c.notifications = NotificationModel()\ |
36 .get_for_user(self.rhodecode_user.user_id) | 37 .get_for_user(self.rhodecode_user.user_id) |
37 return render('admin/notifications/notifications.html') | 38 return render('admin/notifications/notifications.html') |
39 | |
40 def mark_all_read(self): | |
41 if request.environ.get('HTTP_X_PARTIAL_XHR'): | |
42 nm = NotificationModel() | |
43 # mark all read | |
44 nm.mark_all_read_for_user(self.rhodecode_user.user_id) | |
45 Session.commit() | |
46 c.user = self.rhodecode_user | |
47 c.notifications = nm.get_for_user(self.rhodecode_user.user_id) | |
48 return render('admin/notifications/notifications_data.html') | |
38 | 49 |
39 def create(self): | 50 def create(self): |
40 """POST /_admin/notifications: Create a new item""" | 51 """POST /_admin/notifications: Create a new item""" |
41 # url('notifications') | 52 # url('notifications') |
42 | 53 |