This commit is contained in:
Faheedkhan 2025-07-01 19:55:14 +03:00
parent 34558952e8
commit d085940fca
2 changed files with 80 additions and 91 deletions

View File

@ -652,11 +652,16 @@ def inventory_table(context, queryset):
@register.filter
<<<<<<< HEAD
def count_checked(permissions):
"""Count how many permissions are marked as checked"""
print(permissions)
return sum(1 for perm in permissions if getattr(perm, 'is_checked', False))
def count_checked(permissions, group_permission_ids):
"""Count how many permissions are checked from the allowed list"""
if not group_permission_ids:
return 0
return sum(1 for perm in permissions if perm.id in group_permission_ids)
# @register.filter
# def count_checked(permissions, group_permission_ids):
# """Count how many permissions are checked from the allowed list"""
# return sum(1 for perm in permissions if perm.id in group_permission_ids)
@ -673,15 +678,3 @@ def subtract(value, arg):
return float(value) - float(arg)
except (ValueError, TypeError):
return '' # Or raise an error, or return value if conversion fails
=======
def count_checked(permissions, group_permission_ids):
"""Count how many permissions are checked from the allowed list"""
if not group_permission_ids:
return 0
return sum(1 for perm in permissions if perm.id in group_permission_ids)
# @register.filter
# def count_checked(permissions, group_permission_ids):
# """Count how many permissions are checked from the allowed list"""
# return sum(1 for perm in permissions if perm.id in group_permission_ids)
>>>>>>> 68f7e3fb2c4f4aeb23ae96a9431dade25885d274

View File

@ -26,7 +26,6 @@
<form method="post" novalidate>
{% csrf_token %}
<!-- Filter and Summary Section -->
<div class="row mb-4">
<div class="col-md-6">
<div class="input-group">
@ -43,11 +42,9 @@
</div>
</div>
<!-- Permissions Grid -->
<!-- Permissions Grid -->
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4" id="permissionsGrid">
{% for app_label, models in grouped_permissions.items %}
<div class="col">
<div class="col"> {# This div opens for each app_label #}
<div class="card h-100 border-{% if app_label in group_permission_apps %}primary{% else %}light{% endif %}">
<div class="card-header bg-{% if app_label in group_permission_apps %}primary text-white{% else %}light{% endif %}">
<div class="d-flex justify-content-between align-items-center">
@ -74,6 +71,7 @@
<i class="fas fa-{% if model == 'Custom' %}star{% else %}table{% endif %} me-2"></i>
{{ model|capfirst }}
<span class="badge bg-{% if model in group_permission_models %}primary{% else %}secondary{% endif %} rounded-pill ms-2">
{# This is where you might need the custom filter 'count_checked' #}
{{ perms|length }} / {{ perms|count_checked:group_permission_ids }}
</span>
</button>
@ -115,12 +113,10 @@
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
<!-- Footer section remains the same -->
</div>
<div class="row mt-4 mb-4">
<div class="col">