Skip to content

Commit

Permalink
Merge branch 'master' into issue_397
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Howitz committed May 27, 2019
2 parents 3ebdd45 + 57da264 commit c3a34d7
Show file tree
Hide file tree
Showing 6 changed files with 384 additions and 279 deletions.
5 changes: 5 additions & 0 deletions CHANGES.rst
Expand Up @@ -38,6 +38,11 @@ Fixes
(`#629 <https://github.com/zopefoundation/Zope/issues/629>`_).
Minor cleanup of ``HTTPRequest.get``.

Other changes
+++++++++++++

- Fixed usability on ZMI Security tab forms for sites with many roles


4.0 (2019-05-10)
----------------
Expand Down
317 changes: 191 additions & 126 deletions src/OFS/dtml/access.dtml
@@ -1,134 +1,199 @@
<dtml-var manage_page_header>

<dtml-with "_(management_view='Security')"
><dtml-if manage_tabs
><dtml-var manage_tabs
></dtml-if
></dtml-with>
<dtml-with "_(management_view='Security')">
<dtml-if manage_tabs>
<dtml-var manage_tabs>
</dtml-if>
</dtml-with>

<main class="container-fluid">

<p class="form-help mb-4">
The listing below shows the current security settings for this item.
Permissions are rows and roles are columns. Checkboxes are used to
indicate where roles are assigned permissions. You can also assign
<strong><a href="manage_listLocalRoles">local roles</a></strong> to
users, which give users extra roles in the context of this object and
its subobjects.<br />
When a role is assigned to a permission, users with the given role
will be able to perform tasks associated with the permission on this
item. When the <em>Acquire permission settings</em> checkbox is selected
then the containing objects's permission settings are used. Note: the
acquired permission settings may be augmented by selecting Roles for
a permission in addition to selecting to acquire permissions.
</p>

<form action="manage_reportUserPermissions" method="get" class="mb-4">
<div class="form-group row form-inline">
<label for="username" class="col-sm-3 col-md-2">Username:</label>
<div class="col-sm-9 col-md-10">
<input class="form-control mr-3" type="text" id="username" name="user"
required="required" placeholder="Enter name of user ..." />
<input type="submit"
class="btn btn-primary mr-sm-2"
title="Show me the user permissions and roles in the context of the current object"
value="Show permissions" />
<input type="button"
class="btn btn-primary mr-3"
title="Add a New Local Roles for the entered or any other User Name"
onclick="window.location.href='manage_listLocalRoles?username=' + $('#username').val()"
value="Assign Local Roles" />
</div>
</div>
</form>

<dtml-with expr="_.namespace(valid_roles=valid_roles())">
<form action="manage_changePermissions" method="post">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th scope="col" colspan="2" class="zmi-table-head-permisions">Permissions</th>
<th scope="col" colspan="<dtml-var expr="_.len(valid_roles)">" class="zmi-table-head-roles">Roles</th>
<th class="blank">&nbsp;</th>
</tr>
</thead>
<tbody>
<dtml-in permission_settings mapping
><dtml-let permmission_title="name"
><dtml-if "not (_['sequence-index']%10)">
<tr class="zmi-table-head">
<th class="zmi-akcquire-title" title="Acquire?">
<dtml-unless isTopLevelPrincipiaApplicationObject>
<a href="manage_acquiredForm">Acquire?</a>
</dtml-unless>
</th>
<th class="zmi-permission" title="Permission">Permission</th>
<dtml-in valid_roles>
<th class="zmi-rolename" title="&dtml-sequence-item;"><div><span>&dtml-sequence-item;</span></div></th>
</dtml-in>
<th class="blank"><div><span>&nbsp;</span></div></th>
</tr>
</dtml-if>
<tr>
<td class="zmi-akcquire-check">
<dtml-if isTopLevelPrincipiaApplicationObject>&nbsp;<dtml-else
><input type="checkbox" name="acquire_&dtml-hashed_name;" &dtml-acquire; />
</dtml-if>
</td>
<td class="zmi-akcquire-title nowrap">
<a href="manage_permissionForm?permission_to_manage=&dtml.url_quote-name;">&dtml-name;</a>
</td>
<dtml-in roles mapping
><td class="zmi-rolename-check" title="Role: <dtml-var "valid_roles[_['sequence-index']]">"
onclick="$(this).children('input').trigger('click')">
<label class="sr-only sr-only-focusable"
for="&dtml-name;">Role: <dtml-var "valid_roles[_['sequence-index']]">, Permission: <dtml-var "_['permmission_title']"></label>
<input type="checkbox" &dtml-checked; id="&dtml-name;" name="&dtml-name;" onclick="event.stopPropagation()" />
</td>
</dtml-in>
<td class="blank">&nbsp;</td>
</tr>
</dtml-let
></dtml-in permission_settings
></tbody>
</table>
<div class="zmi-controls">
<input type="submit" class="btn btn-primary" name="submit" value="Save Changes" />
</div>
</form>
</dtml-with>


<dtml-if "_['id'] != 'acl_users'">

<p class="form-help mt-4">
You can define new roles by entering a role name and clicking the
&quot;Add Role&quot; button.
</p>

<form action="manage_defined_roles" method="post" class="form">
<div class="form-group">
<label for="username" class="nowrap">User defined roles</label>
<div class="form-inline">
<input type="text" class="form-control col-sm-6 col-md-3 mr-2 mb-2" id="role" name="role" placeholder="Define a new user role ..." />
<input type="submit" class="btn btn-primary mb-2" name="submit" value="Add Role" />
</div>
</div>
<dtml-if userdefined_roles>
<div class="form-group">
<div class="form-inline">
<select name="roles:list" class="form-control col-sm-6 col-md-3 mr-2 mb-2">
<dtml-in userdefined_roles>
<option value="&dtml-sequence-item;">&dtml-sequence-item;</option>
</dtml-in>
</select>
<input type="submit" class="btn btn-primary mb-2" name="submit" value="Delete Role" />
</div>
</div>
</dtml-if>
</form>
</dtml-if>
<dtml-let roles="valid_roles()"
short_form="len(roles) > 20">

<p class="form-help mb-4">
The listing below shows the current security settings for this item.
You can also assign
<strong><a href="manage_listLocalRoles">local roles</a></strong> to
users, which give users extra roles in the context of this object and
its subobjects.<br />
</p>

<form action="manage_reportUserPermissions" method="get" class="mb-4">
<div class="form-group row form-inline">
<label for="username" class="col-sm-3 col-md-2">Username:</label>
<div class="col-sm-9 col-md-10">
<input class="form-control mr-3" type="text" id="username" name="user"
required="required" placeholder="Enter name of user ..." />
<input type="submit"
class="btn btn-primary mr-sm-2"
title="Show user permissions and roles in the context of the current object"
value="Show permissions" />
<input type="button"
class="btn btn-primary mr-3"
title="Add a New Local Role for the entered or any other User Name"
onclick="window.location.href='manage_listLocalRoles?username=' + $('#username').val()"
value="Assign Local Roles" />
</div>
</div>
</form>

<hr/>

<dtml-if short_form>

<h3>Permissions</h3>

<p class="form-help mb-4">
Click on one of the permission names to see the roles they are assigned
to.
</p>

<table>
<dtml-in "ac_inherited_permissions(1)">
<tr>
<td class="zmi-akcquire-title nowrap">
<dtml-let pname="_['sequence-key']">
<a href="manage_permissionForm?permission_to_manage=&dtml.url_quote-pname;">&dtml-pname;</a>
</dtml-let>
</td>
</tr>
</dtml-in>
</table>

<dtml-else>

<h3>Role to permission assignments</h3>

<p class="form-help mb-4">
This table shows which permissions are assigned to each role. Permissions
are rows and roles are columns.<br/>
When a role is assigned to a permission, users with the given role
will be able to perform tasks associated with the permission on this
item.
<dtml-unless isTopLevelPrincipiaApplicationObject>
<br/>
When the <em>Acquire?</em> checkbox is selected
then the containing objects's permission settings are used. Note: the
acquired permission settings may be augmented by selecting Roles for
a permission in addition to selecting to acquire permissions.
</dtml-unless>
</p>

<dtml-with "_.namespace(valid_roles=roles)">
<form action="manage_changePermissions" method="post">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th scope="col" colspan="2" class="zmi-table-head-permisions">
Permissions
</th>
<th scope="col" colspan="<dtml-var expr="_.len(valid_roles)">"
class="zmi-table-head-roles">Roles</th>
<th class="blank">&nbsp;</th>
</tr>
</thead>
<tbody>

<dtml-in permission_settings mapping>
<dtml-let permmission_title="name">
<dtml-if "not (_['sequence-index']%10)">
<tr class="zmi-table-head">
<th class="zmi-akcquire-title" title="Acquire?">
<dtml-unless isTopLevelPrincipiaApplicationObject>
<a href="manage_acquiredForm">Acquire?</a>
</dtml-unless>
</th>
<th class="zmi-permission" title="Permission">Permission</th>
<dtml-in valid_roles>
<th class="zmi-rolename" title="&dtml-sequence-item;">
<div><span>&dtml-sequence-item;</span></div>
</th>
</dtml-in>
<th class="blank"><div><span>&nbsp;</span></div></th>
</tr>
</dtml-if>
<tr>
<td class="zmi-akcquire-check">
<dtml-if isTopLevelPrincipiaApplicationObject>
&nbsp;
<dtml-else>
<input type="checkbox" name="acquire_&dtml-hashed_name;"
&dtml-acquire; />
</dtml-if>
</td>
<td class="zmi-akcquire-title nowrap">
<a href="manage_permissionForm?permission_to_manage=&dtml.url_quote-name;">&dtml-name;</a>
</td>
<dtml-in roles mapping>
<td class="zmi-rolename-check"
title="Role: <dtml-var "valid_roles[_['sequence-index']]">"
onclick="$(this).children('input').trigger('click')">
<label class="sr-only sr-only-focusable"
for="&dtml-name;">
Role: <dtml-var "valid_roles[_['sequence-index']]">,
Permission: <dtml-var "_['permmission_title']">
</label>
<input type="checkbox" &dtml-checked; id="&dtml-name;"
name="&dtml-name;" onclick="event.stopPropagation()" />
</td>
</dtml-in>
<td class="blank">&nbsp;</td>
</tr>
</dtml-let>
</dtml-in permission_settings>

</tbody>
</table>

<div class="zmi-controls">
<input type="submit" class="btn btn-primary" name="submit"
value="Save Changes" />
</div>
</form>
</dtml-with>

</dtml-if short_form>

</dtml-let>

<dtml-if "_['id'] != 'acl_users'">

<hr/>

<h3>Add or delete user-defined roles</h3>

<p class="form-help mt-4">
You can define new roles by entering a role name and clicking the
&quot;Add Role&quot; button.
</p>

<form action="manage_defined_roles" method="post" class="form">
<div class="form-group">
<label for="username" class="nowrap">User defined roles</label>
<div class="form-inline">
<input type="text" class="form-control col-sm-6 col-md-3 mr-2 mb-2"
id="role" name="role" placeholder="Define a new user role ..." />
<input type="submit" class="btn btn-primary mb-2" name="submit"
value="Add Role" />
</div>
</div>
<dtml-if userdefined_roles>
<div class="form-group">
<div class="form-inline">
<select name="roles:list"
class="form-control col-sm-6 col-md-3 mr-2 mb-2">
<dtml-in userdefined_roles>
<option value="&dtml-sequence-item;">&dtml-sequence-item;</option>
</dtml-in>
</select>
<input type="submit" class="btn btn-primary mb-2" name="submit"
value="Delete Role" />
</div>
</div>
</dtml-if>
</form>
</dtml-if>
</main>

<dtml-var manage_page_footer>

0 comments on commit c3a34d7

Please sign in to comment.