From 5286eb540f4a1e2c229fc8f7ba7f0915c4021cd1 Mon Sep 17 00:00:00 2001 From: Mojtaba-z Date: Tue, 23 Dec 2025 12:23:00 +0330 Subject: [PATCH] import - org_id in params for childs & org linked ranchers --- apps/authentication/api/v1/api.py | 12 ++++++++---- apps/herd/web/api/v1/api.py | 7 ++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/authentication/api/v1/api.py b/apps/authentication/api/v1/api.py index 99be036..8e40706 100644 --- a/apps/authentication/api/v1/api.py +++ b/apps/authentication/api/v1/api.py @@ -376,11 +376,15 @@ class OrganizationViewSet(BaseViewSet, ModelViewSet, DynamicSearchMixin): @transaction.atomic def get_child_organizations(self, request): organization = get_organization_by_user(request.user) - child_organizations = self.get_all_org_child(organization) + query_params = self.request.query_params # noqa + # search & filter - queryset = self.filter_query( - self.get_queryset() - ) if not 'org_id' in self.request.query_params.keys() else self.get_all_org_child(organization) + if not 'org_id' in query_params.keys(): # noqa + queryset = self.filter_query( + self.get_queryset() + ) + else: + queryset = self.get_all_org_child(Organization.objects.get(id=query_params.get('org_id'))) page = self.paginate_queryset(queryset) # paginate queryset diff --git a/apps/herd/web/api/v1/api.py b/apps/herd/web/api/v1/api.py index 0973496..2f543f6 100644 --- a/apps/herd/web/api/v1/api.py +++ b/apps/herd/web/api/v1/api.py @@ -302,7 +302,12 @@ class RancherOrganizationLinkViewSet( """ list of organizations with rancher information """ - org = get_organization_by_user(request.user) + query_params = self.request.query_params # noqa + if not 'org_id' in query_params.keys(): + org = get_organization_by_user(request.user) + else: + org = Organization.objects.get(id=query_params.get('org_id')) + result = self.orgs_linked_rancher(org=org, org_type_key='CO') page = self.paginate_queryset(result) # paginate queryset