Browse Source

Just mark all notifications read. closes #466

pull/477/merge
Ruud 13 years ago
parent
commit
4206c2b0dd
  1. 16
      couchpotato/core/notifications/core/main.py
  2. 3
      couchpotato/core/notifications/core/static/notification.js

16
couchpotato/core/notifications/core/main.py

@ -35,7 +35,7 @@ class CoreNotifier(Notification):
addApiView('notification.markread', self.markAsRead, docs = {
'desc': 'Mark notifications as read',
'params': {
'ids': {'desc': 'Notification id you want to mark as read.', 'type': 'int (comma separated)'},
'ids': {'desc': 'Notification id you want to mark as read. All if ids is empty.', 'type': 'int (comma separated)'},
},
})
@ -56,12 +56,18 @@ class CoreNotifier(Notification):
def markAsRead(self):
ids = [x.strip() for x in getParam('ids').split(',')]
ids = None
if getParam('ids'):
ids = [x.strip() for x in getParam('ids').split(',')]
db = get_session()
q = db.query(Notif) \
.filter(or_(*[Notif.id == tryInt(s) for s in ids]))
if ids:
q = db.query(Notif).filter(or_(*[Notif.id == tryInt(s) for s in ids]))
else:
q = db.query(Notif).filter_by(read = False)
q.update({Notif.read: True})
db.commit()
@ -83,6 +89,8 @@ class CoreNotifier(Notification):
limit = splt[0]
offset = 0 if len(splt) is 1 else splt[1]
q = q.limit(limit).offset(offset)
else:
q = q.limit(200)
results = q.all()
notifications = []

3
couchpotato/core/notifications/core/static/notification.js

@ -77,9 +77,6 @@ var NotificationBase = new Class({
if(ids.length > 0)
Api.request('notification.markread', {
'data': {
'ids': ids.join(',')
},
'onSuccess': function(){
self.setBadge('')
}

Loading…
Cancel
Save