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