From b1ac3fa94fbc33b2be027ce7d90fc3d485aae733 Mon Sep 17 00:00:00 2001 From: xinwen Date: Thu, 15 Oct 2020 17:56:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(orgs):=20=E6=9B=B4=E6=96=B0=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E6=97=B6`org=5Froles`=E5=8F=82=E6=95=B0=E4=B8=BA`None?= =?UTF-8?q?`=E6=97=B6=E4=B8=8D=E6=9B=B4=E6=96=B0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E8=A7=92=E8=89=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/users/api/user.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/users/api/user.py b/apps/users/api/user.py index 42cfa0f04..65bd8f4d1 100644 --- a/apps/users/api/user.py +++ b/apps/users/api/user.py @@ -55,11 +55,13 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet): post_user_create.send(self.__class__, user=user) @staticmethod - def set_users_to_org(users, org_roles): + def set_users_to_org(users, org_roles, update=False): # 只有真实存在的组织才真正关联用户 if not current_org or not current_org.is_real(): return for user, roles in zip(users, org_roles): + if update and roles is None: + continue if not roles: # 当前组织创建的用户,至少是该组织的`User` roles = [ORG_ROLE.USER] @@ -107,7 +109,7 @@ class UserViewSet(CommonApiMixin, UserQuerysetMixin, BulkModelViewSet): users = serializer.save() if isinstance(users, User): users = [users] - self.set_users_to_org(users, org_roles) + self.set_users_to_org(users, org_roles, update=True) def perform_bulk_update(self, serializer): # TODO: 需要测试