show portlet only if there are any notifications

This commit is contained in:
Helmut Merz 2015-10-31 10:05:13 +01:00
parent ec28357ba7
commit a2dca10e15
3 changed files with 10 additions and 2 deletions

View file

@ -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.
>>> notifications.add(d001, person, 'I send myself another letter.')
>>> len(list(notifications.listTracks()))
>>> len(list(notifications.listTracks(unreadOnly=False)))
2
Only unread notifications are listed by default.
>>> len(list(notifications.listTracks()))
1
User interface
--------------

View file

@ -30,6 +30,7 @@ from cybertools.browser.configurator import ViewConfigurator, MacroViewProperty
from cybertools.meta.interfaces import IOptions
from loops.browser.node import NodeView
from loops.organize.party import getPersonForUser
from loops.organize.personal.notification import Notifications
from loops.util import _
@ -105,6 +106,8 @@ class PortletConfigurator(ViewConfigurator):
notif = self.view.globalOptions.organize.showNotifications
if not notif:
return []
if not Notifications(self.person).listTracks(unreadOnly=False):
return []
if isinstance(notif, list):
notifPage = notif[0]
else:

View file

@ -33,7 +33,7 @@ class Notifications(Favorites):
self.context = (baseObject(person).
getLoopsRoot().getRecordManager()['favorites'])
def listTracks(self, unreadOnly=False):
def listTracks(self, unreadOnly=True):
tracks = super(Notifications, self).listTracks(
baseObject(self.person), type='notification')
if unreadOnly: