1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-11-22 01:14:21 +01:00

implementing roles switchs on forms

This commit is contained in:
kakwa 2015-06-10 19:59:35 +02:00
parent 70ef41b312
commit 8d08cf0284
3 changed files with 46 additions and 1 deletions

View File

@ -287,6 +287,8 @@ class LdapCherry(object):
self.temp_searchadmin = self.temp_lookup.get_template('searchadmin.tmpl')
self.temp_searchuser = self.temp_lookup.get_template('searchuser.tmpl')
self.temp_adduser = self.temp_lookup.get_template('adduser.tmpl')
self.temp_roles = self.temp_lookup.get_template('roles.tmpl')
self.temp_groups = self.temp_lookup.get_template('groups.tmpl')
self.temp_form = self.temp_lookup.get_template('form.tmpl')
self.temp_selfmodify = self.temp_lookup.get_template('selfmodify.tmpl')
@ -446,7 +448,8 @@ class LdapCherry(object):
""" add user page """
self._check_auth(must_admin=True)
form = self.temp_form.render(attributes=self.attributes.attributes, values=None)
return self.temp_adduser.render(form=form)
roles = self.temp_roles.render(roles=self.roles.flatten, graph=self.roles.graph)
return self.temp_adduser.render(form=form, roles=roles)
@cherrypy.expose
def delete(self, **params):

View File

@ -6,7 +6,10 @@
<div class="col-md-8 column">
<div class="well well-sm">
<form method='POST' action='/adduser' role="form" class="form-signin" data-toggle="validator">
<h2 class="h3">Fill user attributes:</h2>
${form}
<h2 class="h3">Enable/Disable roles:</h2>
${roles}
<div class="form-group">
<div class="input-group">
<button class="btn btn-default green" type="submit">

View File

@ -0,0 +1,39 @@
<table id="RecordTable" class="table table-hover table-condensed tablesorter">
<thead>
<tr>
<th>
Role
</th>
<th>
Parent roles
</th>
<th class="sorter-false">
Enable/Disable
</th>
</tr>
</thead>
<tbody>
%for role in roles:
<tr>
<td>
${roles[role]['display_name']}
</td>
<td>
<%
sep = ', '
parents_roles = []
for r in graph[role]['parent_roles']:
parents_roles.append(roles[r]['display_name'])
parents = sep.join(parents_roles)
%>
${parents}
</td>
<td>
<input data-on-text="Enabled" data-off-text="Disabled" data-handle-width="90" type="checkbox" name="${role}" data-size="mini">
<script>$("[name='${role}']").bootstrapSwitch();</script>
</td>
</tr>
% endfor
</tbody>
</table>