1
0
mirror of https://github.com/kakwa/ldapcherry synced 2024-06-04 18:17:47 +02:00

implementing notification to explain automatic adding of roles

This commit is contained in:
kakwa 2015-06-12 00:25:17 +02:00
parent 5ddaa4c44f
commit 6eece6f7ff
3 changed files with 22 additions and 4 deletions

View File

@ -464,8 +464,12 @@ class LdapCherry(object):
p = list(self.roles.graph[r]['parent_roles'])
graph[r] = { 'sub_roles': s, 'parent_roles': p}
graph_js = json.dumps(graph, separators=(',',':'))
display_names = {}
for r in self.roles.flatten:
display_names[r] = self.roles.flatten[r]['display_name']
roles_js = json.dumps(display_names, separators=(',',':'))
form = self.temp_form.render(attributes=self.attributes.attributes, values=None)
roles = self.temp_roles.render(roles=self.roles.flatten, graph=self.roles.graph, graph_js=graph_js)
roles = self.temp_roles.render(roles=self.roles.flatten, graph=self.roles.graph, graph_js=graph_js, roles_js=roles_js)
return self.temp_adduser.render(form=form, roles=roles, is_admin=is_admin)
@cherrypy.expose

View File

@ -34,6 +34,7 @@
<script type="text/javascript" src="/static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/js/scripts.js"></script>
<script type="text/javascript" src="/static/js/validator.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-notify.js"></script>
<script type="text/javascript" src="/static/js/jquery.tablesorter.min.js"></script>
<script type="text/javascript" src="/static/js/bootstrap-switch.js"></script>

View File

@ -1,19 +1,32 @@
<script type="text/javascript">
var roles = ${graph_js};
var graph = ${graph_js};
var roles = ${roles_js};
function enableParentRoles(roleid){
var parentRoles = roles[roleid]['parent_roles'];
var parentRoles = graph[roleid]['parent_roles'];
var DnRole = roles[roleid];
var len = parentRoles.length;
for (var i = 0; i < len; i++) {
var role = parentRoles[i];
var DnParentRole = roles[role];
var checked = document.getElementById(role).checked;
$('input[name=' + role +']').bootstrapSwitch('state', true, true);
if ( ! checked){
$.notify("Added Role '" + DnParentRole + "' (Parent Role of '" + DnRole +"')");
}
}
}
function disableSubRoles(roleid){
var parentRoles = roles[roleid]['sub_roles'];
var parentRoles = graph[roleid]['sub_roles'];
var DnRole = roles[roleid];
var len = parentRoles.length;
for (var i = 0; i < len; i++) {
var role = parentRoles[i];
var DnParentRole = roles[role];
var checked = document.getElementById(role).checked;
$('input[name=' + role +']').bootstrapSwitch('state', false, true);
if (checked){
$.notify("Removed Role '" + DnParentRole + "' (Sub Role of '" + DnRole +"')");
}
}
}
</script>