Browse Source

fix: 账号导入500 (#10255)

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

3
apps/accounts/serializers/account/account.py

@ -75,6 +75,9 @@ class AccountCreateUpdateSerializerMixin(serializers.Serializer):
initial_data['name'] = name
def from_template_if_need(self, initial_data):
if isinstance(initial_data, str):
return
template_id = initial_data.pop('template', None)
if not template_id:
return

6
apps/assets/serializers/asset/common.py

@ -70,9 +70,13 @@ class AssetPlatformSerializer(serializers.ModelSerializer):
class AssetAccountSerializer(AccountSerializer):
add_org_fields = False
asset = serializers.PrimaryKeyRelatedField(queryset=Asset.objects, required=False, write_only=True)
clone_id: str
clone_id = None
def to_internal_value(self, data):
# 导入时,data有时为str
if isinstance(data, str):
return super().to_internal_value(data)
clone_id = data.pop('id', None)
ret = super().to_internal_value(data)
self.clone_id = clone_id

Loading…
Cancel
Save