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:
Lance Edgar 2015-07-16 17:11:25 -05:00
parent bafa1a0fd7
commit e0cb47d03a
2 changed files with 44 additions and 1 deletions

View 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

View file

@ -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')