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

View file

@ -25,6 +25,7 @@ from zope.app.pagetemplate import ViewPageTemplateFile
from zope.cachedescriptors.property import Lazy from zope.cachedescriptors.property import Lazy
from loops.browser.concept import ConceptView from loops.browser.concept import ConceptView
from loops.organize.personal.notification import Notifications
from loops.organize.party import getPersonForUser from loops.organize.party import getPersonForUser
from loops import util from loops import util
@ -42,3 +43,10 @@ class NotificationsListing(ConceptView):
def person(self): def person(self):
return getPersonForUser(self.context, self.request) 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>Text</th>
<th>Date/Time read</th> <th>Date/Time read</th>
</tr> </tr>
<tr tal:repeat="notif item/getNotifications">
<td colspan="5"
tal:content="notif" />
</tr>
</table> </table>
</div> </div>
</metal:block> </metal:block>

View file

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