process optional selection criteria (dateFrom) for notifications list
This commit is contained in:
parent
8f12304074
commit
dc75d56951
1 changed files with 13 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 Helmut Merz helmutm@cy55.de
|
# Copyright (c) 2017 Helmut Merz helmutm@cy55.de
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
Notifications listing.
|
Notifications listing.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import datetime
|
||||||
from zope import component
|
from zope import component
|
||||||
from zope.app.pagetemplate import ViewPageTemplateFile
|
from zope.app.pagetemplate import ViewPageTemplateFile
|
||||||
from zope.cachedescriptors.property import Lazy
|
from zope.cachedescriptors.property import Lazy
|
||||||
|
@ -31,6 +32,7 @@ from loops.browser.node import NodeView
|
||||||
from loops.common import adapted, baseObject
|
from loops.common import adapted, baseObject
|
||||||
from loops.organize.personal.notification import Notifications
|
from loops.organize.personal.notification import Notifications
|
||||||
from loops.organize.party import getPersonForUser
|
from loops.organize.party import getPersonForUser
|
||||||
|
from loops.organize.work.browser import parseDate
|
||||||
from loops import util
|
from loops import util
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,8 +62,13 @@ class NotificationsListing(ConceptView):
|
||||||
|
|
||||||
def getNotificationsFormatted(self):
|
def getNotificationsFormatted(self):
|
||||||
unreadOnly = not self.request.form.get('show_all')
|
unreadOnly = not self.request.form.get('show_all')
|
||||||
|
dateFrom = self.request.form.get('notifications_from')
|
||||||
|
if dateFrom:
|
||||||
|
dateFrom = parseDate(dateFrom)
|
||||||
result = []
|
result = []
|
||||||
for track in self.getNotifications(unreadOnly):
|
for track in self.getNotifications(unreadOnly):
|
||||||
|
if dateFrom and track.timeStamp < dateFrom:
|
||||||
|
continue
|
||||||
data = track.data
|
data = track.data
|
||||||
s = util.getObjectForUid(data.get('sender'))
|
s = util.getObjectForUid(data.get('sender'))
|
||||||
if s is None:
|
if s is None:
|
||||||
|
@ -87,6 +94,11 @@ class NotificationsListing(ConceptView):
|
||||||
result.append(item)
|
result.append(item)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@Lazy
|
||||||
|
def defaultStartDate(self):
|
||||||
|
value = datetime.date.today() - datetime.timedelta(90)
|
||||||
|
return value.isoformat()[:10]
|
||||||
|
|
||||||
|
|
||||||
class NotificationsView(NodeView, NotificationsListing):
|
class NotificationsView(NodeView, NotificationsListing):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue