Add list of assigned users to role view page.
This surely could be better still; at least this is *something*.
This commit is contained in:
parent
bafa1a0fd7
commit
e0cb47d03a
37
tailbone/templates/roles/read.mako
Normal file
37
tailbone/templates/roles/read.mako
Normal file
|
@ -0,0 +1,37 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
<%inherit file="/roles/crud.mako" />
|
||||
|
||||
${parent.body()}
|
||||
|
||||
<h2>Users</h2>
|
||||
|
||||
% if role is guest_role:
|
||||
|
||||
<p>The guest role is implied for all users.</p>
|
||||
|
||||
% elif role.users:
|
||||
|
||||
<p>The following users are assigned to this role:</p>
|
||||
<br />
|
||||
<div class="grid clickable">
|
||||
<table>
|
||||
<thead>
|
||||
<th>Username</th>
|
||||
<th>Full Name</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
% for i, user in enumerate(role.users, 1):
|
||||
<tr class="${'odd' if i % 2 else 'even'}" url="${url('user.read', uuid=user.uuid)}">
|
||||
<td>${user.username}
|
||||
<td>${user.display_name}</td>
|
||||
</tr>
|
||||
% endfor
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
% else:
|
||||
|
||||
<p>There are no users assigned to this role.</p>
|
||||
|
||||
% endif
|
|
@ -260,6 +260,12 @@ class RoleCrud(CrudView):
|
|||
])
|
||||
return fs
|
||||
|
||||
def template_kwargs(self, form):
|
||||
kwargs = super(RoleCrud, self).template_kwargs(form)
|
||||
kwargs['role'] = form.fieldset.model
|
||||
kwargs['guest_role'] = guest_role(Session)
|
||||
return kwargs
|
||||
|
||||
def pre_delete(self, model):
|
||||
admin = administrator_role(Session())
|
||||
guest = guest_role(Session())
|
||||
|
@ -295,7 +301,7 @@ def includeme(config):
|
|||
|
||||
config.add_route('role.read', '/roles/{uuid}')
|
||||
config.add_view(RoleCrud, attr='read', route_name='role.read',
|
||||
renderer='/roles/crud.mako',
|
||||
renderer='/roles/read.mako',
|
||||
permission='roles.read')
|
||||
|
||||
config.add_route('role.update', '/roles/{uuid}/edit')
|
||||
|
|
Loading…
Reference in a new issue