From ddbcbb0d6628188df4752c6203cfc6804fbc9421 Mon Sep 17 00:00:00 2001
From: feng626 <1304903146@qq.com>
Date: Tue, 22 Mar 2022 16:14:25 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?=
 =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=A7=92=E8=89=B2=E9=87=8D=E5=A4=A7bug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 apps/users/models/user.py      | 4 ++--
 apps/users/serializers/user.py | 2 ++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/apps/users/models/user.py b/apps/users/models/user.py
index 013f2dda0..d5f9f7b72 100644
--- a/apps/users/models/user.py
+++ b/apps/users/models/user.py
@@ -237,16 +237,16 @@ class RoleManager(models.Manager):
 
 class OrgRoleManager(RoleManager):
     def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
         from rbac.const import Scope
         self.scope = Scope.org
+        super().__init__(*args, **kwargs)
 
 
 class SystemRoleManager(RoleManager):
     def __init__(self, *args, **kwargs):
-        super().__init__(*args, **kwargs)
         from rbac.const import Scope
         self.scope = Scope.system
+        super().__init__(*args, **kwargs)
 
 
 class RoleMixin:
diff --git a/apps/users/serializers/user.py b/apps/users/serializers/user.py
index 7421c9cc1..b998e8f6d 100644
--- a/apps/users/serializers/user.py
+++ b/apps/users/serializers/user.py
@@ -49,6 +49,8 @@ class RolesSerializerMixin(serializers.Serializer):
             return fields
 
         action = view.action or 'list'
+        if action in ('partial_bulk_update', 'bulk_update', 'partial_update', 'update'):
+            action = 'create'
         model_cls_field_mapper = {
             SystemRoleBinding: ['system_roles', 'system_roles_display'],
             OrgRoleBinding: ['org_roles', 'system_roles_display']