show portlet only if there are any notifications
This commit is contained in:
parent
ec28357ba7
commit
a2dca10e15
3 changed files with 10 additions and 2 deletions
|
@ -146,9 +146,14 @@ When the notification is marked as read the read timestamp will be set.
|
||||||
It's possible to store more than one notification concerning the same object.
|
It's possible to store more than one notification concerning the same object.
|
||||||
|
|
||||||
>>> notifications.add(d001, person, 'I send myself another letter.')
|
>>> notifications.add(d001, person, 'I send myself another letter.')
|
||||||
>>> len(list(notifications.listTracks()))
|
>>> len(list(notifications.listTracks(unreadOnly=False)))
|
||||||
2
|
2
|
||||||
|
|
||||||
|
Only unread notifications are listed by default.
|
||||||
|
|
||||||
|
>>> len(list(notifications.listTracks()))
|
||||||
|
1
|
||||||
|
|
||||||
User interface
|
User interface
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@ from cybertools.browser.configurator import ViewConfigurator, MacroViewProperty
|
||||||
from cybertools.meta.interfaces import IOptions
|
from cybertools.meta.interfaces import IOptions
|
||||||
from loops.browser.node import NodeView
|
from loops.browser.node import NodeView
|
||||||
from loops.organize.party import getPersonForUser
|
from loops.organize.party import getPersonForUser
|
||||||
|
from loops.organize.personal.notification import Notifications
|
||||||
from loops.util import _
|
from loops.util import _
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,6 +106,8 @@ class PortletConfigurator(ViewConfigurator):
|
||||||
notif = self.view.globalOptions.organize.showNotifications
|
notif = self.view.globalOptions.organize.showNotifications
|
||||||
if not notif:
|
if not notif:
|
||||||
return []
|
return []
|
||||||
|
if not Notifications(self.person).listTracks(unreadOnly=False):
|
||||||
|
return []
|
||||||
if isinstance(notif, list):
|
if isinstance(notif, list):
|
||||||
notifPage = notif[0]
|
notifPage = notif[0]
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -33,7 +33,7 @@ class Notifications(Favorites):
|
||||||
self.context = (baseObject(person).
|
self.context = (baseObject(person).
|
||||||
getLoopsRoot().getRecordManager()['favorites'])
|
getLoopsRoot().getRecordManager()['favorites'])
|
||||||
|
|
||||||
def listTracks(self, unreadOnly=False):
|
def listTracks(self, unreadOnly=True):
|
||||||
tracks = super(Notifications, self).listTracks(
|
tracks = super(Notifications, self).listTracks(
|
||||||
baseObject(self.person), type='notification')
|
baseObject(self.person), type='notification')
|
||||||
if unreadOnly:
|
if unreadOnly:
|
||||||
|
|
Loading…
Add table
Reference in a new issue