From 7b0993959e9d3e102348616c1ffe5f8c5aa1611b Mon Sep 17 00:00:00 2001 From: xinwen Date: Thu, 21 May 2020 15:40:41 +0800 Subject: [PATCH] [Update] orgs.serializers.OrgReadSerializer add `id` --- apps/orgs/serializers.py | 7 ++++--- apps/users/serializers/user.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/orgs/serializers.py b/apps/orgs/serializers.py index 5ff3b5f4d..fbff6106c 100644 --- a/apps/orgs/serializers.py +++ b/apps/orgs/serializers.py @@ -6,6 +6,7 @@ from users.models import User, UserGroup from assets.models import Asset, Domain, AdminUser, SystemUser, Label from perms.models import AssetPermission from common.serializers import AdaptedBulkListSerializer +from users.serializers import UserOrgSerializer from .utils import set_current_org, get_current_org from .models import Organization from .mixins.serializers import OrgMembershipSerializerMixin @@ -20,9 +21,9 @@ class OrgSerializer(ModelSerializer): class OrgReadSerializer(ModelSerializer): - admins = serializers.SlugRelatedField(slug_field='name', many=True, read_only=True) - auditors = serializers.SlugRelatedField(slug_field='name', many=True, read_only=True) - users = serializers.SlugRelatedField(slug_field='name', many=True, read_only=True) + admins = UserOrgSerializer(many=True, read_only=True) + auditors = UserOrgSerializer(many=True, read_only=True) + users = UserOrgSerializer(many=True, read_only=True) user_groups = serializers.SerializerMethodField() assets = serializers.SerializerMethodField() domains = serializers.SerializerMethodField() diff --git a/apps/users/serializers/user.py b/apps/users/serializers/user.py index a0c56e8e6..99e1d23f4 100644 --- a/apps/users/serializers/user.py +++ b/apps/users/serializers/user.py @@ -14,7 +14,7 @@ from ..models import User __all__ = [ 'UserSerializer', 'UserPKUpdateSerializer', 'ChangeUserPasswordSerializer', 'ResetOTPSerializer', - 'UserProfileSerializer', + 'UserProfileSerializer', 'UserOrgSerializer' ]