Commit acb12545 authored by pengxiong's avatar pengxiong

新建自定义模版

parent ec03c6d1
......@@ -57,10 +57,22 @@ def get_default_template(args):
def add_template(args):
"""新建模版"""
type = args.get('type')
custom_template = json.loads(args.get('custom_template'))
with TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_diagnose_session = tamp_diagnose_app.session
args['id'] = str(uuid.uuid4())
args['default_template'] = json.dumps(hold_default_template)
if type == 1:
allowed_keys = hold_default_template.keys()
for key in list(custom_template.keys()):
if key not in allowed_keys:
custom_template.pop(key)
elif type == 2:
allowed_keys = diagnose_default_template.keys()
for key in list(custom_template.keys()):
if key not in allowed_keys:
custom_template.pop(key)
args['custom_template'] = json.dumps(custom_template)
args['create_by'] = args.get('ifa_id')
args['create_time'] = datetime.datetime.now()
fund_report_manange = FundReportManange(**args)
......@@ -68,7 +80,7 @@ def add_template(args):
def update_template(args):
"""更新模版"""
template_data = args.get('template_data')
template_data = json.loads(args.get('template_data'))
with TAMP_SQL(tamp_diagnose_app_engine) as tamp_diagnose_app:
tamp_diagnose_session = tamp_diagnose_app.session
res = tamp_diagnose_session.query(FundReportManange).filter(and_(
......@@ -79,7 +91,7 @@ def update_template(args):
return False
if res[0].default_template:
allowed_keys = json.loads(res[0].default_template).keys()
for key, value in template_data.items():
for key in list(template_data.keys()):
if key not in allowed_keys:
template_data.pop(key)
# 更新默认模版
......
......@@ -18,6 +18,6 @@ def login_require(func):
ifa_id = redis.get(token)
if not ifa_id:
return {"code": '9005', "message": "请登录", "attributes": []}
g.ifa_id = ifa_id.decode().replace('\'', '')
g.ifa_id = ifa_id.decode().replace('\"', '')
return func(*args, **kwargs)
return auth
\ No newline at end of file
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