work in progress: notification listing; improve 'unauthorized' view

This commit is contained in:
Helmut Merz 2015-10-23 10:36:46 +02:00
parent c029cb2356
commit 019eef29a6
4 changed files with 18 additions and 2 deletions

View file

@ -20,6 +20,7 @@
Login, logout, unauthorized stuff.
"""
from zope.app.exception.browser.unauthorized import Unauthorized as DefaultUnauth
from zope.app.security.interfaces import IAuthentication
from zope.app.security.interfaces import ILogout, IUnauthenticatedPrincipal
from zope import component
@ -87,5 +88,8 @@ class Unauthorized(ConceptView):
response.setHeader('Expires', 'Mon, 26 Jul 1997 05:00:00 GMT')
response.setHeader('Cache-Control', 'no-store, no-cache, must-revalidate')
response.setHeader('Pragma', 'no-cache')
if self.nodeView is None:
v = DefaultUnauth(self.context, self.request)
return v()
url = self.nodeView.topMenu.url
response.redirect(url + '/unauthorized')

View file

@ -25,6 +25,7 @@ from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy
from loops.browser.concept import ConceptView
from loops.organize.personal.notification import Notifications
from loops.organize.party import getPersonForUser
from loops import util
@ -42,3 +43,10 @@ class NotificationsListing(ConceptView):
def person(self):
return getPersonForUser(self.context, self.request)
@Lazy
def notifications(self):
return Notifications(self.person)
def getNotifications(self, unreadOnly=True):
tracks = self.notifications.listTracks()
return tracks

View file

@ -58,6 +58,10 @@
<th>Text</th>
<th>Date/Time read</th>
</tr>
<tr tal:repeat="notif item/getNotifications">
<td colspan="5"
tal:content="notif" />
</tr>
</table>
</div>
</metal:block>

View file

@ -35,11 +35,11 @@ class Notifications(Favorites):
def listTracks(self):
return super(Notifications, self).listTracks(
self.person, type='notification')
baseObject(self.person), type='notification')
def add(self, obj, sender, text):
senderUid = util.getUidForObject(baseObject(sender))
super(Notifications, self).add(obj, self.person,
super(Notifications, self).add(baseObject(obj), baseObject(self.person),
dict(type='notification', sender=senderUid, text=text),
nodups=False)