Just mark all notifications read. closes #466
This commit is contained in:
1 parent
d98ffbf7da
commit
4206c2b0dd
2 files changed
+12
-7
No files matched your search
@@ -35,7 +35,7 @@ class CoreNotifier(Notification):
|
|||||||
addApiView('notification.markread', self.markAsRead, docs = {
|
addApiView('notification.markread', self.markAsRead, docs = {
|
||||||
'desc': 'Mark notifications as read',
|
'desc': 'Mark notifications as read',
|
||||||
'params': {
|
'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):
|
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()
|
db = get_session()
|
||||||
|
|
||||||
q = db.query(Notif) \
|
if ids:
|
||||||
.filter(or_(*[Notif.id == tryInt(s) for s in 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})
|
q.update({Notif.read: True})
|
||||||
|
|
||||||
db.commit()
|
db.commit()
|
||||||
@@ -83,6 +89,8 @@ class CoreNotifier(Notification):
|
|||||||
limit = splt[0]
|
limit = splt[0]
|
||||||
offset = 0 if len(splt) is 1 else splt[1]
|
offset = 0 if len(splt) is 1 else splt[1]
|
||||||
q = q.limit(limit).offset(offset)
|
q = q.limit(limit).offset(offset)
|
||||||
|
else:
|
||||||
|
q = q.limit(200)
|
||||||
|
|
||||||
results = q.all()
|
results = q.all()
|
||||||
notifications = []
|
notifications = []
|
||||||
|
|||||||
@@ -77,9 +77,6 @@ var NotificationBase = new Class({
|
|||||||
|
|
||||||
if(ids.length > 0)
|
if(ids.length > 0)
|
||||||
Api.request('notification.markread', {
|
Api.request('notification.markread', {
|
||||||
'data': {
|
|
||||||
'ids': ids.join(',')
|
|
||||||
},
|
|
||||||
'onSuccess': function(){
|
'onSuccess': function(){
|
||||||
self.setBadge('')
|
self.setBadge('')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user