diff --git a/.gitignore b/.gitignore index 195cc59e..cf4a11de 100644 --- a/.gitignore +++ b/.gitignore @@ -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/ diff --git a/inventory/templatetags/custom_filters.py b/inventory/templatetags/custom_filters.py index b5adad28..06a338bf 100644 --- a/inventory/templatetags/custom_filters.py +++ b/inventory/templatetags/custom_filters.py @@ -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)) \ No newline at end of file + 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 \ No newline at end of file diff --git a/templates/groups/group_list.html b/templates/groups/group_list.html index dafbbb28..4f4a011b 100644 --- a/templates/groups/group_list.html +++ b/templates/groups/group_list.html @@ -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 %} {{ group.name }} - {{ group.users.count }} + {{ group.users.count|subtract:1}} {{ group.permissions.count }}