Browse Source

perf: 修复创建资产时,account 的校验 (#10247)

* perf: 修复创建资产时,account 的校验

* perf: 优化一下提示

---------

Co-authored-by: ibuler <ibuler@qq.com>
pull/10250/head
fit2bot 2 years ago committed by GitHub
parent
commit
28f08251b3
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

@ -53,7 +53,7 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
for data in initial_data:
if not data.get('asset') and not self.instance:
raise serializers.ValidationError({'asset': 'Asset is required'})
raise serializers.ValidationError({'asset': UniqueTogetherValidator.missing_message})
asset = data.get('asset') or self.instance.asset
self.from_template_if_need(data)
self.set_uniq_name_if_need(data, asset)
@ -111,8 +111,9 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
_validators = super().get_validators()
if getattr(self, 'initial_data', None) is None:
return _validators
on_invalid = self.initial_data.get('on_invalid')
if on_invalid == AccountInvalidPolicy.ERROR:
if on_invalid == AccountInvalidPolicy.ERROR and not self.parent:
return _validators
_validators = [v for v in _validators if not isinstance(v, UniqueTogetherValidator)]
return _validators

Loading…
Cancel
Save