From c7dfd0edce5c340919340ef28661463d6267865e Mon Sep 17 00:00:00 2001 From: "fghbng@qq.com" Date: Fri, 14 May 2021 19:16:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=88=E6=9D=83=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=B3=BB=E7=BB=9F=E7=94=A8=E6=88=B7=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/perms/serializers/asset/permission.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/apps/perms/serializers/asset/permission.py b/apps/perms/serializers/asset/permission.py index 1ee95afee..f00b0d606 100644 --- a/apps/perms/serializers/asset/permission.py +++ b/apps/perms/serializers/asset/permission.py @@ -83,22 +83,14 @@ class AssetPermissionSerializer(BulkOrgResourceModelSerializer): return queryset def to_internal_value(self, data): - if not data['assets']: - data['assets'] = [] - if not data['system_users']: - data['system_users'] = [] - if not data['users']: - data['users'] = [] - if not data['user_groups']: - data['user_groups'] = [] - if not data['nodes']: - data['nodes'] = [] # 系统用户是必填项 + system_users = data.get('system_users', []) system_users_display = data.pop('system_users_display', '') for i in range(len(system_users_display)): system_user = SystemUser.objects.filter(name=system_users_display[i]).first() - if system_user and system_user.id not in data['system_users']: - data['system_users'].append(system_user.id) + if system_user and system_user.id not in system_users: + system_users.append(system_user.id) + data['system_users'] = system_users return super().to_internal_value(data) def perform_display_create(self, instance, **kwargs):