fix: 删除组织角色时 判断全局绑定用户数量 (#7774)

Co-authored-by: feng626 <1304903146@qq.com>
pull/7775/head
fit2bot 2022-03-08 20:00:19 +08:00 committed by GitHub
parent 9492518773
commit 42ebb1f82f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -27,12 +27,14 @@ class RoleViewSet(JMSModelViewSet):
}
def perform_destroy(self, instance):
from orgs.utils import tmp_to_root_org
if instance.builtin:
error = _("Internal role, can't be destroy")
raise PermissionDenied(error)
if instance.users.count() >= 1:
error = _("The role has been bound to users, can't be destroy")
raise PermissionDenied(error)
with tmp_to_root_org():
if instance.users.count() >= 1:
error = _("The role has been bound to users, can't be destroy")
raise PermissionDenied(error)
return super().perform_destroy(instance)
def perform_update(self, serializer):