mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-14 23:10:15 +02:00
Include states in permission auditing
This commit is contained in:
parent
13b0dbc960
commit
54262a850d
@ -33,6 +33,15 @@
|
|||||||
{% include 'permissions_tool/audit_row.html' %}
|
{% include 'permissions_tool/audit_row.html' %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% 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 %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
{% load i18n %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{% if forloop.first %}
|
||||||
|
<b>{% trans 'State' %}: {{ state }}</b>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ user }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
@ -41,7 +41,7 @@
|
|||||||
{% trans "Groups" %}
|
{% trans "Groups" %}
|
||||||
</th>
|
</th>
|
||||||
<th class="col-md-1">
|
<th class="col-md-1">
|
||||||
{% trans "Groups Users" %}
|
{% trans "States" %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@ -66,10 +66,10 @@
|
|||||||
{{ perm.users }}
|
{{ perm.users }}
|
||||||
</td>
|
</td>
|
||||||
<td class="{% if perm.groups > 0 %}info {% endif %}text-right">
|
<td class="{% if perm.groups > 0 %}info {% endif %}text-right">
|
||||||
{{ perm.groups }}
|
{{ perm.groups }} ({{ perm.group_users }})
|
||||||
</td>
|
</td>
|
||||||
<td class="{% if perm.group_users > 0 %}info {% endif %}text-right">
|
<td class="{% if perm.states > 0 %}info {% endif %}text-right">
|
||||||
{{ perm.group_users }}
|
{{ perm.states }} ({{ perm.state_users }})
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.contrib.auth.models import Permission
|
from django.contrib.auth.models import Permission, User
|
||||||
from django.shortcuts import render, get_object_or_404
|
from django.shortcuts import render, get_object_or_404
|
||||||
from django.db.models import Count
|
from django.db.models import Count
|
||||||
|
from authentication.models import UserProfile
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -22,14 +23,16 @@ def permissions_overview(request):
|
|||||||
this_perm = {
|
this_perm = {
|
||||||
'users': perm.user_set.all().count(),
|
'users': perm.user_set.all().count(),
|
||||||
'groups': perm.group_set.all().count(),
|
'groups': perm.group_set.all().count(),
|
||||||
|
'states': perm.state_set.all().count(),
|
||||||
'permission': perm
|
'permission': perm
|
||||||
}
|
}
|
||||||
|
|
||||||
if get_all or this_perm['users'] > 0 or this_perm['groups'] > 0:
|
if get_all or this_perm['users'] > 0 or this_perm['groups'] > 0 or this_perm['states'] > 0:
|
||||||
# Only add if we're getting everything or one of the objects has this permission
|
# Only add if we're getting everything or one of the objects has this permission
|
||||||
# Add group_users separately to improve performance
|
# Add group_users separately to improve performance
|
||||||
this_perm['group_users'] = sum(group.user_count for group in
|
this_perm['group_users'] = sum(group.user_count for group in
|
||||||
perm.group_set.annotate(user_count=Count('user')))
|
perm.group_set.annotate(user_count=Count('user')))
|
||||||
|
this_perm['state_users'] = UserProfile.objects.filter(state__in=perm.state_set.all()).count()
|
||||||
context['permissions'].append(this_perm)
|
context['permissions'].append(this_perm)
|
||||||
|
|
||||||
return render(request, 'permissions_tool/overview.html', context=context)
|
return render(request, 'permissions_tool/overview.html', context=context)
|
||||||
@ -48,7 +51,9 @@ def permissions_audit(request, app_label, model, codename):
|
|||||||
'permission': perm,
|
'permission': perm,
|
||||||
'users': perm.user_set.all(),
|
'users': perm.user_set.all(),
|
||||||
'groups': perm.group_set.all(),
|
'groups': perm.group_set.all(),
|
||||||
'group_users': [group.user_set.all() for group in perm.group_set.all()]
|
'states': perm.state_set.all(),
|
||||||
|
'group_users': [group.user_set.all() for group in perm.group_set.all()],
|
||||||
|
'state_users': User.objects.filter(profile__state__in=perm.state_set.all()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user