{% extends 'base.html' %} {% load static %} {% block title %}Permission Usage Analytics{% endblock %} {% block extra_css %} {% endblock %} {% block content %}

🔑 Permission Usage Analytics

{% if suggestions %}
💡 Optimization Suggestions
{% for suggestion in suggestions %}
{{ suggestion.title }}

{{ suggestion.description }}

{% if suggestion.permissions %}
Affected permissions:
{% for permission in suggestion.permissions %} {{ permission }} {% endfor %}
{% endif %}
{{ suggestion.impact|title }} Impact
{% endfor %}
{% endif %}
📊 Permission Usage Frequency
{% for usage in permission_usage %} {% empty %} {% endfor %}
Permission Total Checks Granted Denied Users Grant Rate
{{ usage.permission_checked }} {{ usage.total_checks }} {{ usage.granted_count }} {{ usage.denied_count }} {{ usage.unique_users }} {% with grant_rate=usage.granted_count|floatformat:0|add:0 total=usage.total_checks|floatformat:0|add:0 %} {% if total > 0 %} {% widthratio grant_rate total 100 as percentage %}
{{ percentage }}%
{% else %} N/A {% endif %} {% endwith %}
No permission usage data available
📊 Most Denied Permissions
Permission Changes by Role
{% for role in role_permission_changes %}
{{ role.user__role|title }}
{{ role.total_changes }} total changes
+{{ role.grants }} grants
-{{ role.revokes }} revokes
{% empty %}

No role permission changes in this period

{% endfor %}
Users with Most Denials
{% for user in users_with_denials %} {% empty %} {% endfor %}
User Role Denials Permissions
{{ user.user__first_name }} {{ user.user__last_name }} {{ user.user__role|title }} {{ user.denial_count }} {{ user.unique_permissions }}
No denial data available
{% if unused_permissions %}
Unused Permissions ({{ unused_permissions|length }} total)

These permissions haven't been checked in the last {{ days }} days and may be candidates for removal:

{% for permission in unused_permissions %} {{ permission }} {% endfor %}
{% endif %}
📈 Permission Usage Trends
Detailed Permission Analysis

{{ permission_usage|length }}

Active Permissions

{{ unused_permissions|length }}

Unused Permissions

{% if permission_usage %} {% with total_checks=0 total_granted=0 %} {% for usage in permission_usage %} {% with total_checks=total_checks|add:usage.total_checks total_granted=total_granted|add:usage.granted_count %} {% endwith %} {% endfor %} {% if total_checks > 0 %} {% widthratio total_granted total_checks 100 %}% {% else %} 0% {% endif %} {% endwith %} {% else %} 0% {% endif %}

Average Grant Rate
{% endblock %} {% block extra_js %} {% endblock %}