new version of workspace assignments view with predicate columns

git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@4079 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
helmutm 2010-11-24 11:01:45 +00:00
parent b794361116
commit 0332f9a2e1
3 changed files with 45 additions and 2 deletions

View file

@ -882,6 +882,12 @@ To be done...
[u'Note', u'Type']
Security
========
>>> from loops.security.browser import admin, audit
Import/Export
=============

View file

@ -53,6 +53,30 @@
<metal:macro define-macro="workspace_assignments">
<metal:headline use-macro="view/concept_macros/concepttitle" />
<table class="listing">
<tr>
<th></th>
<th class="center"
tal:repeat="pred item/workspacePredicates"
tal:content="pred/title" />
</tr>
<tr tal:repeat="ws item/workspaces"
tal:attributes="class python: repeat['ws'].odd() and 'even' or 'odd';">
<td>
<a tal:attributes="href python:view.getUrlForTarget(ws)"
tal:content="ws/title" /></td>
<td class="center"
tal:repeat="rels python:item.getAssignments(ws)">
<div tal:repeat="rel rels">
<a tal:attributes="href python:view.getUrlForTarget(rel.second)"
tal:content="rel/second/title" /></div></td>
</tr>
</table>
</metal:macro>
<metal:macro define-macro="person_workspace_assignments">
<metal:headline use-macro="view/concept_macros/concepttitle" />
<table class="listing">
<tr>

View file

@ -109,7 +109,7 @@ class WorkspaceAssignments(BaseSecurityView):
return self.template.macros['workspace_assignments']
@Lazy
def workspacePrediactes(self):
def workspacePredicates(self):
result = [self.conceptManager.get(p)
for p in ('isowner', 'ismaster', 'ismember')]
return [p for p in result if p is not None]
@ -122,6 +122,19 @@ class WorkspaceAssignments(BaseSecurityView):
return type.getChildren([self.typePredicate])
return []
def getAssignments(self, workspace):
rels = []
for wsp in self.workspacePredicates:
rels.append(workspace.getChildRelations([wsp]))
return rels
class PersonWorkspaceAssignments(WorkspaceAssignments):
@Lazy
def macro(self):
return self.template.macros['person_workspace_assignments']
@Lazy
def persons(self):
tPerson = self.conceptManager['person']
@ -130,5 +143,5 @@ class WorkspaceAssignments(BaseSecurityView):
def getAssignments(self, person):
rels = []
for ws in self.workspaces:
rels.append(ws.getChildRelations(self.workspacePrediactes, person))
rels.append(ws.getChildRelations(self.workspacePredicates, person))
return [', '.join([r.predicate.title for r in prels]) for prels in rels]