From f6c6aa7abb8ef2b4bb7aca9275587ffa51a22067 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Mon, 27 Oct 2025 16:37:56 +0330 Subject: [PATCH] fix connectionless permissions by role & relation --- apps/authorization/api/v1/api.py | 5 ++++- logs/django_requests.log | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/authorization/api/v1/api.py b/apps/authorization/api/v1/api.py index b3a2419..29f05c8 100644 --- a/apps/authorization/api/v1/api.py +++ b/apps/authorization/api/v1/api.py @@ -108,7 +108,10 @@ class PermissionViewSet(SoftDeleteMixin, viewsets.ModelViewSet): def connectionless_permissions(self, request, *args, **kwargs): """ get all permissions that are not assigned to any user relation """ - permissions = Permissions.objects.annotate(num=Count('userrelations')).filter(num=0) # noqa + permissions = Permissions.objects.annotate( + user_relation_num=Count('userrelations'), # noqa + role_num=Count('role'), + ).filter(user_relation_num=0, role_num=0) # noqa page = self.paginate_queryset(permissions) if page is not None: diff --git a/logs/django_requests.log b/logs/django_requests.log index 8f91376..a19b04e 100644 --- a/logs/django_requests.log +++ b/logs/django_requests.log @@ -37,3 +37,5 @@ [2025-10-27 16:22:54,143] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\core\api.py changed, reloading. [2025-10-27 16:22:56,067] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader [2025-10-27 16:26:54,114] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\core\api.py changed, reloading. +[2025-10-27 16:26:55,924] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-10-27 16:37:24,219] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authorization\api\v1\api.py changed, reloading.