Commit 66139239 authored by pengxiong's avatar pengxiong

更新模版修复

parent 0fddbcf0
...@@ -71,6 +71,7 @@ def add_template(args): ...@@ -71,6 +71,7 @@ def add_template(args):
def update_template(args): def update_template(args):
"""更新模版""" """更新模版"""
template_data = args.get('template_data')
with TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app: with TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_diagnose_session = tamp_diagnose_app.session tamp_diagnose_session = tamp_diagnose_app.session
res = tamp_diagnose_session.query(FundReportManange).filter(and_( res = tamp_diagnose_session.query(FundReportManange).filter(and_(
...@@ -80,18 +81,26 @@ def update_template(args): ...@@ -80,18 +81,26 @@ def update_template(args):
if not res: if not res:
return False return False
if res[0].default_template: if res[0].default_template:
allowed_keys = json.loads(res[0].default_template).keys()
for key, value in template_data.items():
if key not in allowed_keys:
template_data.pop(key)
# 更新默认模版 # 更新默认模版
res.update({ res.update({
'default_template': args.get('template_data'), 'default_template': json.dumps(template_data),
'update_by': args.get('ifa_id'), 'update_by': args.get('ifa_id'),
'update_time': datetime.datetime.now() 'update_time': datetime.datetime.now()
}) })
else: else:
allowed_keys = json.loads(res[0].custom_template).keys()
for key, value in template_data.items():
if key not in allowed_keys:
template_data.pop(key)
# 更新自定义模版 # 更新自定义模版
args['update_by'] = args.get('ifa_id') args['update_by'] = args.get('ifa_id')
args['update_time'] = datetime.datetime.now() args['update_time'] = datetime.datetime.now()
res.update({ res.update({
'custom_template': args.get('template_data'), 'custom_template': json.dumps(template_data),
'update_by': args.get('ifa_id'), 'update_by': args.get('ifa_id'),
'update_time': datetime.datetime.now() 'update_time': datetime.datetime.now()
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment