Browse Source

fix: 更新账号 跳过name检查 (#10136)

Co-authored-by: feng <1304903146@qq.com>
pull/10138/head
fit2bot 2 years ago committed by GitHub
parent
commit
7c1e92c787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      apps/accounts/serializers/account/account.py

5
apps/accounts/serializers/account/account.py

@ -55,11 +55,12 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
self.from_template_if_need(data)
self.set_uniq_name_if_need(data, asset)
@staticmethod
def set_uniq_name_if_need(initial_data, asset):
def set_uniq_name_if_need(self, initial_data, asset):
name = initial_data.get('name')
if not name:
name = initial_data.get('username')
if self.instance and self.instance.name == name:
return
if Account.objects.filter(name=name, asset=asset).exists():
name = name + '_' + uuid.uuid4().hex[:4]
initial_data['name'] = name

Loading…
Cancel
Save