[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/Security/Grants/Views/Browser - RolePermissionView.py:1.2 manage_access.pt:1.4
Florent Guillaume
fg@nuxeo.com
Mon, 24 Jun 2002 12:00:45 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/Security/Grants/Views/Browser
In directory cvs.zope.org:/tmp/cvs-serv11631/Views/Browser
Modified Files:
RolePermissionView.py manage_access.pt
Log Message:
Update Role Permission UI to allow Unset/Allow/Deny.
Fix tests, including dummy RolePermissionManager.
Correct interface assertions.
=== Zope3/lib/python/Zope/App/Security/Grants/Views/Browser/RolePermissionView.py 1.1 => 1.2 ===
# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
# All Rights Reserved.
-#
+#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
-#
+#
##############################################################################
"""
@@ -23,14 +23,14 @@
from Zope.App.Security.IRolePermissionManager import IRolePermissionManager
from Zope.App.Security.Grants.PermissionRoles import PermissionRoles
from Zope.App.Security.Grants.RolePermissions import RolePermissions
-
+from Zope.App.Security.Settings import Unset, Allow, Deny
class RolePermissionView(BrowserView):
index = ViewPageTemplateFile('manage_access.pt')
manage_permissionForm = ViewPageTemplateFile('manage_permissionForm.pt')
manage_roleForm = ViewPageTemplateFile('manage_roleForm.pt')
-
+
def roles(self):
roles = getattr(self, '_roles', None)
if roles is None:
@@ -47,7 +47,12 @@
).getPermissions()
return permissions
-
+ def availableSettings(self):
+ return [{'id': Unset.getName(), 'title': ' '},
+ {'id': Allow.getName(), 'title': '+'},
+ {'id': Deny.getName(), 'title': '-'},
+ ]
+
def permissionRoles(self):
context = self.context
roles = self.roles()
@@ -68,7 +73,6 @@
).getRole(rid)
return RolePermissions(role, context, permissions)
-
def action(self, REQUEST, testing=None):
roles = [r.getId() for r in self.roles()]
permissions = [p.getId() for p in self.permissions()]
@@ -79,10 +83,16 @@
for ir in range(len(roles)):
rrole = REQUEST.get("r%s" % ir)
if rrole not in roles: continue
- if ("p%sr%s" % (ip, ir)) in REQUEST:
- prm.grantPermissionToRole(rperm, rrole)
- else:
- prm.unsetPermissionFromRole(rperm, rrole)
+ setting = REQUEST.get("p%sr%s" % (ip, ir), None)
+ if setting is not None:
+ if setting == Unset.getName():
+ prm.unsetPermissionFromRole(rperm, rrole)
+ elif setting == Allow.getName():
+ prm.grantPermissionToRole(rperm, rrole)
+ elif setting == Deny.getName():
+ prm.denyPermissionToRole(rperm, rrole)
+ else:
+ raise ValueError("Incorrect setting: %s" % setting)
if not testing:
return self.index( REQUEST,
=== Zope3/lib/python/Zope/App/Security/Grants/Views/Browser/manage_access.pt 1.3 => 1.4 ===
</div>
</td>
- <td align="center" tal:repeat="role perm/roles">
- <input type="checkbox" name="p0r0"
- tal:attributes="
- CHECKED role;
- name string:p${repeat/perm/index}r${repeat/role/index}"
- />
+ <td align="center" tal:repeat="setting perm/roleSettings">
+ <select name="p0r0"
+ tal:attributes="name string:p${repeat/perm/index}r${repeat/setting/index}">
+ <option value="Unset"
+ tal:repeat="option view/availableSettings"
+ tal:attributes="value option/id;
+ selected python:setting == option['id']"
+ tal:content="option/title">+</option>
+ </select>
</td>
</tr>
</tbody>