notifications: portlet, translations

This commit is contained in:
Helmut Merz 2015-10-30 12:52:42 +01:00
parent 4a0b31b34d
commit ec28357ba7
6 changed files with 81 additions and 7 deletions

Binary file not shown.

View file

@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: 0.13.0\n" "Project-Id-Version: 0.13.0\n"
"POT-Creation-Date: 2007-05-22 12:00 CET\n" "POT-Creation-Date: 2007-05-22 12:00 CET\n"
"PO-Revision-Date: 2013-07-15 12:00 CET\n" "PO-Revision-Date: 2015-10-30 12:00 CET\n"
"Last-Translator: Helmut Merz <helmutm@cy55.de>\n" "Last-Translator: Helmut Merz <helmutm@cy55.de>\n"
"Language-Team: loops developers <helmutm@cy55.de>\n" "Language-Team: loops developers <helmutm@cy55.de>\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
@ -483,6 +483,30 @@ msgstr "Lesezeichen für aktuelles Objekt hinzufügen"
msgid "Remove from favorites" msgid "Remove from favorites"
msgstr "Lesezeichen entfernen" msgstr "Lesezeichen entfernen"
msgid "Notifications"
msgstr "Nachrichten"
msgid "No new notifications"
msgstr "Keine neuen Nachrichten"
msgid "${numNews} new notification"
msgstr "${numNews} neue Nachricht"
msgid "${numNews} new notifications"
msgstr "${numNews} neue Nachrichten"
msgid "Show all notifications"
msgstr "Alle Nachrichten anzeigen"
msgid "Sender"
msgstr "Absender"
msgid "Object"
msgstr "Objekt"
msgid "Date/Time Read"
msgstr "Gelesen"
msgid "Personal Informations" msgid "Personal Informations"
msgstr "Persönliche Informationen" msgstr "Persönliche Informationen"

View file

@ -1,5 +1,5 @@
# #
# Copyright (c) 2010 Helmut Merz helmutm@cy55.de # Copyright (c) 2015 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
@ -18,8 +18,6 @@
""" """
A view configurator provides configuration data for a view controller. A view configurator provides configuration data for a view controller.
$Id$
""" """
from zope import component from zope import component
@ -30,6 +28,7 @@ from zope.traversing.browser.absoluteurl import absoluteURL
from cybertools.browser.configurator import ViewConfigurator, MacroViewProperty 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.organize.party import getPersonForUser from loops.organize.party import getPersonForUser
from loops.util import _ from loops.util import _
@ -44,10 +43,11 @@ class PortletConfigurator(ViewConfigurator):
def __init__(self, context, request): def __init__(self, context, request):
self.context = context self.context = context
self.request = request self.request = request
self.view = NodeView(self.context, self.request)
@property @property
def viewProperties(self): def viewProperties(self):
return self.favorites + self.filters return self.favorites + self.filters + self.notifications
@Lazy @Lazy
def records(self): def records(self):
@ -97,3 +97,25 @@ class PortletConfigurator(ViewConfigurator):
#url=absoluteURL(self.context, self.request) + '/@@filters.html', #url=absoluteURL(self.context, self.request) + '/@@filters.html',
)) ))
return [filters] return [filters]
@property
def notifications(self):
if self.person is None:
return []
notif = self.view.globalOptions.organize.showNotifications
if not notif:
return []
if isinstance(notif, list):
notifPage = notif[0]
else:
notifPage = 'notifications'
portlet = MacroViewProperty(self.context, self.request)
portlet.setParams(dict(
slot='portlet_left',
identifier='loops.organize.notifications',
title=_(u'Notifications'),
subMacro=personal_macros.macros['notifications_portlet'],
priority=10,
url='%s/%s' % (self.view.menu.url, notifPage),
))
return [portlet]

View file

@ -35,6 +35,12 @@
class="loops.organize.personal.browser.notification.NotificationsListing" class="loops.organize.personal.browser.notification.NotificationsListing"
permission="zope.View" /> permission="zope.View" />
<browser:page
for="loops.interfaces.INode"
name="notifications_view"
class="loops.organize.personal.browser.notification.NotificationsView"
permission="zope.View" />
<zope:adapter <zope:adapter
name="notification_read" name="notification_read"
for="loops.browser.node.NodeView for="loops.browser.node.NodeView

View file

@ -27,6 +27,7 @@ from zope.cachedescriptors.property import Lazy
from cybertools.browser.form import FormController from cybertools.browser.form import FormController
from cybertools.util.date import formatTimeStamp, getTimeStamp from cybertools.util.date import formatTimeStamp, getTimeStamp
from loops.browser.concept import ConceptView from loops.browser.concept import ConceptView
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
@ -50,7 +51,7 @@ class NotificationsListing(ConceptView):
def notifications(self): def notifications(self):
return Notifications(self.person) return Notifications(self.person)
def getNotifications(self, unreadOnly): def getNotifications(self, unreadOnly=True):
tracks = self.notifications.listTracks(unreadOnly) tracks = self.notifications.listTracks(unreadOnly)
return tracks return tracks
@ -78,6 +79,11 @@ class NotificationsListing(ConceptView):
return result return result
class NotificationsView(NodeView, NotificationsListing):
pass
class ReadNotification(FormController): class ReadNotification(FormController):
def update(self): def update(self):

View file

@ -47,6 +47,22 @@
</metal:actions> </metal:actions>
<metal:actions define-macro="notifications_portlet"
tal:define="view nocall:context/@@notifications_view;
numNews python:len(view.getNotifications())">
<div tal:condition="not:numNews"
i18n:translate="">No new notifications</div>
<div tal:condition="python:numNews == 1">
<a i18n:translate=""
tal:attributes="href macro/url">
<span i18n:name="numNews" tal:content="numNews" /> new notification</a></div>
<div tal:condition="python:numNews > 1">
<a i18n:translate=""
tal:attributes="href macro/url">
<span i18n:name="numNews" tal:content="numNews" /> new notifications</a></div>
</metal:actions>
<metal:block define-macro="notifications"> <metal:block define-macro="notifications">
<div tal:attributes="class string:content-$level;"> <div tal:attributes="class string:content-$level;">
<metal:title use-macro="item/concept_macros/concepttitle" /> <metal:title use-macro="item/concept_macros/concepttitle" />
@ -65,7 +81,7 @@
<th i18n:translate="">Sender</th> <th i18n:translate="">Sender</th>
<th i18n:translate="">Object</th> <th i18n:translate="">Object</th>
<th i18n:translate="">Message</th> <th i18n:translate="">Message</th>
<th i18n:translate="">Date/Time read</th> <th i18n:translate="">Date/Time Read</th>
</tr> </tr>
<tr tal:repeat="notif item/getNotificationsFormatted"> <tr tal:repeat="notif item/getNotificationsFormatted">
<td tal:content="notif/timeStamp" /> <td tal:content="notif/timeStamp" />