##// END OF EJS Templates
Added filtering on inbox by comments
marcink -
r2503:d04243e9 beta
parent child Browse files
Show More
@@ -61,10 +61,12 b' class NotificationsController(BaseContro'
61 # url('notifications')
61 # url('notifications')
62 c.user = self.rhodecode_user
62 c.user = self.rhodecode_user
63 notif = NotificationModel().get_for_user(self.rhodecode_user.user_id,
63 notif = NotificationModel().get_for_user(self.rhodecode_user.user_id,
64 filter_=request.GET)
64 filter_=request.GET.getall('type'))
65 p = int(request.params.get('page', 1))
65 p = int(request.params.get('page', 1))
66 c.notifications = Page(notif, page=p, items_per_page=10)
66 c.notifications = Page(notif, page=p, items_per_page=10)
67 c.pull_request_type = Notification.TYPE_PULL_REQUEST
67 c.pull_request_type = Notification.TYPE_PULL_REQUEST
68 c.comment_type = [Notification.TYPE_CHANGESET_COMMENT,
69 Notification.TYPE_PULL_REQUEST_COMMENT]
68 return render('admin/notifications/notifications.html')
70 return render('admin/notifications/notifications.html')
69
71
70 def mark_all_read(self):
72 def mark_all_read(self):
@@ -72,11 +74,11 b' class NotificationsController(BaseContro'
72 nm = NotificationModel()
74 nm = NotificationModel()
73 # mark all read
75 # mark all read
74 nm.mark_all_read_for_user(self.rhodecode_user.user_id,
76 nm.mark_all_read_for_user(self.rhodecode_user.user_id,
75 filter_=request.GET)
77 filter_=request.GET.getall('type'))
76 Session.commit()
78 Session.commit()
77 c.user = self.rhodecode_user
79 c.user = self.rhodecode_user
78 notif = nm.get_for_user(self.rhodecode_user.user_id,
80 notif = nm.get_for_user(self.rhodecode_user.user_id,
79 filter_=request.GET)
81 filter_=request.GET.getall('type'))
80 c.notifications = Page(notif, page=1, items_per_page=10)
82 c.notifications = Page(notif, page=1, items_per_page=10)
81 return render('admin/notifications/notifications_data.html')
83 return render('admin/notifications/notifications_data.html')
82
84
@@ -27,7 +27,6 b''
27 import os
27 import os
28 import logging
28 import logging
29 import traceback
29 import traceback
30 import datetime
31
30
32 from pylons.i18n.translation import _
31 from pylons.i18n.translation import _
33
32
@@ -35,7 +34,6 b' import rhodecode'
35 from rhodecode.lib import helpers as h
34 from rhodecode.lib import helpers as h
36 from rhodecode.model import BaseModel
35 from rhodecode.model import BaseModel
37 from rhodecode.model.db import Notification, User, UserNotification
36 from rhodecode.model.db import Notification, User, UserNotification
38 from sqlalchemy.orm import joinedload
39
37
40 log = logging.getLogger(__name__)
38 log = logging.getLogger(__name__)
41
39
@@ -152,7 +150,7 b' class NotificationModel(BaseModel):'
152 Notification.notification_id))
150 Notification.notification_id))
153
151
154 if filter_:
152 if filter_:
155 q = q.filter(Notification.type_ == filter_.get('type'))
153 q = q.filter(Notification.type_.in_(filter_))
156
154
157 return q.all()
155 return q.all()
158
156
@@ -164,7 +162,7 b' class NotificationModel(BaseModel):'
164 .join((Notification, UserNotification.notification_id ==
162 .join((Notification, UserNotification.notification_id ==
165 Notification.notification_id))
163 Notification.notification_id))
166 if filter_:
164 if filter_:
167 q = q.filter(Notification.type_ == filter_.get('type'))
165 q = q.filter(Notification.type_.in_(filter_))
168
166
169 # this is a little inefficient but sqlalchemy doesn't support
167 # this is a little inefficient but sqlalchemy doesn't support
170 # update on joined tables :(
168 # update on joined tables :(
@@ -24,11 +24,13 b''
24 ## </li>
24 ## </li>
25 ##</ul>
25 ##</ul>
26 </div>
26 </div>
27 %if c.notifications:
27
28 <div style="padding:14px 18px;text-align: right;float:left">
28 <div style="padding:14px 18px;text-align: right;float:left">
29 <span id='all' class="ui-btn"><a href="${h.url.current()}">${_('All')}</a></span>
29 <span id='all' class="ui-btn"><a href="${h.url.current()}">${_('All')}</a></span>
30 <span id='pull_request' class="ui-btn"><a href="${h.url.current(type=c.comment_type)}">${_('Comments')}</a></span>
30 <span id='pull_request' class="ui-btn"><a href="${h.url.current(type=c.pull_request_type)}">${_('Pull requests')}</a></span>
31 <span id='pull_request' class="ui-btn"><a href="${h.url.current(type=c.pull_request_type)}">${_('Pull requests')}</a></span>
31 </div>
32 </div>
33 %if c.notifications:
32 <div style="padding:14px 18px;text-align: right;float:right">
34 <div style="padding:14px 18px;text-align: right;float:right">
33 <span id='mark_all_read' class="ui-btn">${_('Mark all read')}</span>
35 <span id='mark_all_read' class="ui-btn">${_('Mark all read')}</span>
34 </div>
36 </div>
@@ -44,12 +46,8 b" YUE.on(YUQ('.delete-notification'),'clic"
44 deleteNotification(url_del,notification_id)
46 deleteNotification(url_del,notification_id)
45 })
47 })
46 YUE.on('mark_all_read','click',function(e){
48 YUE.on('mark_all_read','click',function(e){
47 var url = "${h.url('notifications_mark_all_read', **request.GET)}";
49 var url = "${h.url('notifications_mark_all_read', **request.GET.mixed())}";
48 ypjax(url,'notification_data',function(){
50 ypjax(url,'notification_data',function(){
49 var notification_counter = YUD.get('notification_counter');
50 if(notification_counter){
51 notification_counter.innerHTML=0;
52 }
53 YUE.on(YUQ('.delete-notification'),'click',function(e){
51 YUE.on(YUQ('.delete-notification'),'click',function(e){
54 var notification_id = e.currentTarget.id;
52 var notification_id = e.currentTarget.id;
55 deleteNotification(url_del,notification_id)
53 deleteNotification(url_del,notification_id)
General Comments 0
You need to be logged in to leave comments. Login now