fix(users): 修改用户角色显示名称

This commit is contained in:
xinwen
2020-08-14 17:09:23 +08:00
committed by 老广
parent 0e0c9275bd
commit af85d551ad
5 changed files with 105 additions and 77 deletions

View File

@@ -111,7 +111,12 @@ class UserSerializer(CommonBulkSerializerMixin, serializers.ModelSerializer):
role._choices = choices
def get_total_role_display(self, instance):
return ' | '.join({str(instance.role_display), str(instance.org_role_display)})
role_display = instance.role_display
org_role_display = instance.org_role_display
if role_display == org_role_display:
return role_display
else:
return f'{role_display} | {org_role_display}'
def validate_role(self, value):
request = self.context.get('request')