Browse Source

fix(users): 组织管理员创建用户时,角色只能选择: 用户

pull/4338/head
Bai 4 years ago committed by BaiJiangJie
parent
commit
bb60d2a1d9
  1. 6
      apps/users/serializers/user.py

6
apps/users/serializers/user.py

@ -87,7 +87,11 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
if not role:
return
choices = role._choices
choices.pop('App', None)
choices.pop(User.ROLE_APP, None)
request = self.context.get('request')
if request and hasattr(request, 'user') and not request.user.is_superuser:
choices.pop(User.ROLE_ADMIN, None)
choices.pop(User.ROLE_AUDITOR, None)
role._choices = choices
def validate_role(self, value):

Loading…
Cancel
Save