fix: 修复创建 es 命令存储后台 meta.hosts 被修改的问题;deepcopy dict list value 在创建操作日志的时候

pull/9588/head^2
Bai 2023-02-16 15:55:33 +08:00 committed by Jiangjie.Bai
parent bfa2e285f5
commit 726f90ab16
2 changed files with 5 additions and 9 deletions

View File

@ -1,4 +1,5 @@
import codecs
import copy
import csv
from itertools import chain
@ -76,8 +77,8 @@ def _get_instance_field_value(
if getattr(f, 'primary_key', False):
f.verbose_name = 'id'
elif isinstance(value, list):
value = [str(v) for v in value]
elif isinstance(value, (list, dict)):
value = copy.deepcopy(value)
elif isinstance(f, models.OneToOneField) and isinstance(value, models.Model):
nested_data = _get_instance_field_value(
value, include_model_fields, model_need_continue_fields, ('id',)

View File

@ -75,14 +75,9 @@ class CommandStorage(CommonStorageModelMixin, JMSBaseModel):
@property
def config(self):
config = self.meta
config = copy.deepcopy(self.meta)
config.update({'TYPE': self.type})
# 处理 hosts 对象, 正常应该是list, 但是有时候是 str, debug 未果
hosts = config.get('HOSTS', [])
if isinstance(hosts, str) and ',' in hosts:
hosts = hosts.split(',')
config['HOSTS'] = hosts
return copy.deepcopy(config)
return config
@property
def valid_config(self):