This commit is contained in:
Faheedkhan 2025-07-01 16:40:09 +03:00
parent bf4a3ea3bd
commit 2adccfc7d0
3 changed files with 21 additions and 3 deletions

3
.gitignore vendored
View File

@ -43,7 +43,7 @@ Makefile
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
**/migrations/
**/*/migrations/
# Gradle
.idea/**/gradle.xml
@ -116,6 +116,7 @@ celerybeat-schedule.*
.venv
env/
venv/
dev_venv/
ENV/
env.bak/
venv.bak/

View File

@ -651,4 +651,20 @@ def inventory_table(context, queryset):
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))
return sum(1 for perm in permissions if getattr(perm, 'is_checked', False))
@register.filter
def subtract(value, arg):
"""
Subtracts the arg from the value.
Example: {{ value|subtract:arg }}
"""
try:
return int(value) - int(arg)
except (ValueError, TypeError):
try:
return float(value) - float(arg)
except (ValueError, TypeError):
return '' # Or raise an error, or return value if conversion fails

View File

@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load i18n %}
{% load custom_filters %}
{% load render_table from django_tables2 %}
{% block title %}{% trans "Groups" %}{% endblock title %}
@ -32,7 +33,7 @@
{% for group in groups %}
<tr>
<td class="align-middle white-space-nowrap ps-1">{{ group.name }}</td>
<td class="align-middle white-space-nowrap"><i class="fa-solid fa-users me-1"></i> {{ group.users.count }}</td>
<td class="align-middle white-space-nowrap"><i class="fa-solid fa-users me-1"></i> {{ group.users.count|subtract:1}}</td>
<td class="align-middle white-space-nowrap"><i class="fa-solid fa-unlock me-1"></i> {{ group.permissions.count }}</td>
<td class="align-middle white-space-nowrap">
<a class="btn btn-phoenix-success"