Fix spr, permissions_tool, improve group_management

This commit is contained in:
ErikKalkoken
2020-02-17 00:59:47 +01:00
parent 8771477884
commit fffb21bb4f
8 changed files with 380 additions and 328 deletions

View File

@@ -11,38 +11,41 @@
<a href="{% url 'permissions_tool:overview' %}" class="btn btn-default">
<i class="glyphicon glyphicon-chevron-left"></i> {% trans "Back" %}
</a>
<table class="table table-hover">
<thead>
<tr>
<th class="col-md-3">
{% trans "Group" %}
</th>
<th class="col-md-3">
{% trans "User" %}
</th>
</tr>
</thead>
<tbody>
{% for user in permission.users %}
<tr>
{% include 'permissions_tool/audit_row.html' with group="Permission Granted Directly (No Group)" %}
</tr>
{% endfor %}
{% for group in permission.groups %}
{% for user in group.user_set.all %}
{% include 'permissions_tool/audit_row.html' %}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th class="col-md-3">
{% trans "Group" %}
</th>
<th class="col-md-3">
{% trans "User" %}
</th>
</tr>
</thead>
<tbody>
{% for user in permission.users %}
<tr>
{% include 'permissions_tool/audit_row.html' with group="Permission Granted Directly (No Group)" %}
</tr>
{% endfor %}
{% endfor %}
{% for state in permission.states %}
{% for profile in state.userprofile_set.all %}
{% with profile.user as user %}
<tr>
{% include 'permissions_tool/audit_state_row.html' %}
</tr>
{% endwith %}
{% for group in permission.groups %}
{% for user in group.user_set.all %}
{% include 'permissions_tool/audit_row.html' %}
{% endfor %}
{% endfor %}
{% endfor %}
</tbody>
</table>
{% for state in permission.states %}
{% for profile in state.userprofile_set.all %}
{% with profile.user as user %}
<tr>
{% include 'permissions_tool/audit_state_row.html' %}
</tr>
{% endwith %}
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}

View File

@@ -19,61 +19,79 @@
<a href="{% url 'permissions_tool:overview' %}?all=no" class="btn btn-primary">{% trans "Show Applied" %}</a>
</span>
{% endif %}
<table class="table table-hover">
<thead>
<tr>
<th>
{% trans "App" %}
</th>
<th>
{% trans "Model" %}
</th>
<th>
{% trans "Code Name" %}
</th>
<th>
{% trans "Name" %}
</th>
<th class="col-md-1">
{% trans "Users" %}
</th>
<th class="col-md-1">
{% trans "Groups" %}
</th>
<th class="col-md-1">
{% trans "States" %}
</th>
</tr>
</thead>
<tbody>
{% for perm in permissions %}
<tr>
<td>
{{ perm.permission.content_type.app_label }}
</td>
<td>
{{ perm.permission.content_type.model }}
</td>
<td>
<a href="{% url "permissions_tool:audit" app_label=perm.permission.content_type.app_label model=perm.permission.content_type.model codename=perm.permission.codename %}">
{{ perm.permission.codename }}
</a>
</td>
<td>
{{ perm.permission.name }}
</td>
<td class="{% if perm.users > 0 %}info {% endif %}text-right">
{{ perm.users }}
</td>
<td class="{% if perm.groups > 0 %}info {% endif %}text-right">
{{ perm.groups }} ({{ perm.group_users }})
</td>
<td class="{% if perm.states > 0 %}info {% endif %}text-right">
{{ perm.states }} ({{ perm.state_users }})
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="table-responsive">
<table class="table table-striped" id="tab_permissions_overview">
<thead>
<tr>
<th>
{% trans "App" %}
</th>
<th>
{% trans "Model" %}
</th>
<th>
{% trans "Code Name" %}
</th>
<th>
{% trans "Name" %}
</th>
<th class="col-md-1">
{% trans "Users" %}
</th>
<th class="col-md-1">
{% trans "Groups" %}
</th>
<th class="col-md-1">
{% trans "States" %}
</th>
</tr>
</thead>
<tbody>
{% for perm in permissions %}
<tr>
<td>
{{ perm.permission.content_type.app_label }}
</td>
<td>
{{ perm.permission.content_type.model }}
</td>
<td>
<a href="{% url "permissions_tool:audit" app_label=perm.permission.content_type.app_label model=perm.permission.content_type.model codename=perm.permission.codename %}">
{{ perm.permission.codename }}
</a>
</td>
<td>
{{ perm.permission.name }}
</td>
<td class="{% if perm.users > 0 %}info {% endif %}text-right">
{{ perm.users }}
</td>
<td class="{% if perm.groups > 0 %}info {% endif %}text-right">
{{ perm.groups }} ({{ perm.group_users }})
</td>
<td class="{% if perm.states > 0 %}info {% endif %}text-right">
{{ perm.states }} ({{ perm.state_users }})
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endblock content %}
{% block extra_javascript %}
{% include 'bundles/datatables-js.html' %}
{% endblock %}
{% block extra_css %}
{% include 'bundles/datatables-css.html' %}
{% endblock %}
{% block extra_script %}
$(document).ready(function(){
$('#tab_permissions_overview').DataTable({
order: [ [ 0, "asc" ], [ 1, "asc" ], [ 2, "asc" ] ]
});
});
{% endblock %}