From cc147eb156823fa6de60026bfdf787d0a2b5647b Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Sat, 29 Jul 2023 13:01:21 +0200 Subject: [PATCH] filter Tenant_User properly in core Tenant Users List api --- skipper/skipper/core/components/tenant/tenant_users.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/skipper/skipper/core/components/tenant/tenant_users.py b/skipper/skipper/core/components/tenant/tenant_users.py index 61c43fc..384ac2a 100644 --- a/skipper/skipper/core/components/tenant/tenant_users.py +++ b/skipper/skipper/core/components/tenant/tenant_users.py @@ -11,6 +11,7 @@ from rest_framework.request import Request from rest_framework.viewsets import ModelViewSet from rest_framework import permissions, serializers +from rest_framework.generics import get_object_or_404 from skipper.core import constants from skipper.core.serializers.base import BaseSerializer @@ -38,6 +39,7 @@ class TenantUserViewSet( ModelViewSet # type: ignore ): skipper_base_name = constants.core_tenant_user_view_set_name + kwargs: Dict[str, Any] def get_serializer_class(self) -> Any: @@ -64,6 +66,9 @@ class Meta: return GenericTenantUserSerializer def get_queryset(self) -> QuerySet[Tenant_User]: - return Tenant_User.objects.all() + tenant = get_object_or_404(Tenant.objects.filter(id=self.kwargs["tenant_id"])) + return Tenant_User.objects.filter( + tenant=tenant + ).all()