From 693b5e1b24bc187ec78dca58db9973f0d22c6f61 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Sun, 2 Nov 2025 14:49:47 +0330 Subject: [PATCH] fix - exclude self org & admin in visible orgs --- apps/authentication/services/visibility_services.py | 5 ++++- logs/django_requests.log | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/apps/authentication/services/visibility_services.py b/apps/authentication/services/visibility_services.py index d5ccc0f..61a0ac0 100644 --- a/apps/authentication/services/visibility_services.py +++ b/apps/authentication/services/visibility_services.py @@ -13,7 +13,10 @@ def get_visible_organizations(org: Organization) -> typing.Any: if org.free_visibility_by_scope: if org.field_of_activity == 'CO': - return Organization.objects.all() + if org.type.key == 'ADM': + return Organization.objects.all() + else: + return Organization.objects.all().exclude(id=org.id).exclude(type__key='ADM') elif org.field_of_activity == 'CI': return Organization.objects.filter(city=org.city) diff --git a/logs/django_requests.log b/logs/django_requests.log index 5e8d8e7..00cb1e1 100644 --- a/logs/django_requests.log +++ b/logs/django_requests.log @@ -681,3 +681,7 @@ AssertionError: .validate() should return the validated data [2025-11-02 13:35:36,007] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader [2025-11-02 13:45:12,453] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\warehouse\web\api\v1\serializers.py changed, reloading. [2025-11-02 13:45:15,794] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-11-02 14:48:20,592] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\services\visibility_services.py changed, reloading. +[2025-11-02 14:48:23,704] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader +[2025-11-02 14:49:21,133] INFO django.utils.autoreload | IP: - | Path: - | D:\Project\Rasaddam_Backend\apps\authentication\services\visibility_services.py changed, reloading. +[2025-11-02 14:49:23,410] INFO django.utils.autoreload | IP: - | Path: - | Watching for file changes with StatReloader