2015-06-27 22:35:34 +02:00
|
|
|
## -*- coding: utf-8 -*-
|
2015-06-11 23:36:50 +02:00
|
|
|
<script type="text/javascript">
|
2015-06-12 00:25:17 +02:00
|
|
|
var graph = ${graph_js};
|
|
|
|
var roles = ${roles_js};
|
2015-06-11 23:36:50 +02:00
|
|
|
function enableParentRoles(roleid){
|
2015-06-12 00:25:17 +02:00
|
|
|
var parentRoles = graph[roleid]['parent_roles'];
|
|
|
|
var DnRole = roles[roleid];
|
2015-06-11 23:36:50 +02:00
|
|
|
var len = parentRoles.length;
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
|
var role = parentRoles[i];
|
2015-06-12 00:25:17 +02:00
|
|
|
var DnParentRole = roles[role];
|
2015-06-24 00:46:10 +02:00
|
|
|
var checked = document.getElementById('role.'+ role).checked;
|
|
|
|
$('input[name="role.' + role +'"]').bootstrapSwitch('state', true, true);
|
2015-06-12 00:25:17 +02:00
|
|
|
if ( ! checked){
|
2015-06-12 01:07:17 +02:00
|
|
|
$.notify("Enable Role '" + DnParentRole + "' (Parent Role of '" + DnRole +"')",
|
|
|
|
{
|
|
|
|
type: 'info',
|
|
|
|
delay: 6500,
|
|
|
|
}
|
|
|
|
);
|
2015-06-12 00:25:17 +02:00
|
|
|
}
|
2015-06-11 23:36:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
function disableSubRoles(roleid){
|
2015-06-12 00:25:17 +02:00
|
|
|
var parentRoles = graph[roleid]['sub_roles'];
|
|
|
|
var DnRole = roles[roleid];
|
2015-06-11 23:36:50 +02:00
|
|
|
var len = parentRoles.length;
|
|
|
|
for (var i = 0; i < len; i++) {
|
|
|
|
var role = parentRoles[i];
|
2015-06-12 00:25:17 +02:00
|
|
|
var DnParentRole = roles[role];
|
2015-06-24 00:46:10 +02:00
|
|
|
var checked = document.getElementById('role.'+role).checked;
|
|
|
|
$('input[name="role.' + role +'"]').bootstrapSwitch('state', false, true);
|
2015-06-12 00:25:17 +02:00
|
|
|
if (checked){
|
2015-06-12 01:07:17 +02:00
|
|
|
$.notify("Disable Role '" + DnParentRole + "' (Sub Role of '" + DnRole +"')",
|
|
|
|
{
|
|
|
|
type: 'warning',
|
|
|
|
delay: 6500,
|
|
|
|
}
|
|
|
|
);
|
2015-06-12 00:25:17 +02:00
|
|
|
}
|
2015-06-11 23:36:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2015-06-10 19:59:35 +02:00
|
|
|
<table id="RecordTable" class="table table-hover table-condensed tablesorter">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
Role
|
|
|
|
</th>
|
2015-06-11 00:33:14 +02:00
|
|
|
<th class="sorter-false">
|
|
|
|
Description
|
|
|
|
</th>
|
2015-06-11 00:11:55 +02:00
|
|
|
<th class="sorter-false">
|
2015-06-10 19:59:35 +02:00
|
|
|
Parent roles
|
|
|
|
</th>
|
|
|
|
<th class="sorter-false">
|
|
|
|
Enable/Disable
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
%for role in roles:
|
2015-06-19 22:15:37 +02:00
|
|
|
<%
|
|
|
|
if not current_roles is None and role in current_roles:
|
|
|
|
checked = ' checked '
|
|
|
|
else:
|
|
|
|
checked = ''
|
|
|
|
%>
|
2015-06-10 19:59:35 +02:00
|
|
|
<tr>
|
|
|
|
<td>
|
|
|
|
${roles[role]['display_name']}
|
|
|
|
</td>
|
2015-06-11 00:33:14 +02:00
|
|
|
<td>
|
|
|
|
${roles[role]['description']}
|
|
|
|
</td>
|
2015-06-10 19:59:35 +02:00
|
|
|
<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>
|
2015-06-11 23:36:50 +02:00
|
|
|
<input data-on-color="success" data-off-color="danger" data-on-text="Enabled"
|
|
|
|
data-off-text="Disabled" data-handle-width="75" type="checkbox"
|
2015-06-24 00:46:10 +02:00
|
|
|
name="role.${role}" data-size="mini" id="role.${role}" ${checked}>
|
|
|
|
<script>$("[name='role.${role}']").bootstrapSwitch();
|
|
|
|
$('input[name="role.${role}"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
2015-06-11 23:36:50 +02:00
|
|
|
if (state) {
|
|
|
|
enableParentRoles('${role}');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
disableSubRoles('${role}');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
</script>
|
2015-06-10 19:59:35 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
% endfor
|
|
|
|
</tbody>
|
|
|
|
</table>
|