Единый и неделимый json-файл

This commit is contained in:
2024-11-22 20:04:20 +03:00
parent 54043aee12
commit cba13f4834
6 changed files with 35 additions and 41 deletions

View File

@@ -26,15 +26,13 @@ def create():
items=report_list,
date_today=date.today())
else:
data = dict(id=request.form.get('category'),
month=request.form.get('month'),
year=request.form.get('year'))
id = request.form.get('category')
month = request.form.get('month')
year = request.form.get('year')
data = dict(id=id, month=month, year=year)
with open(path.join(path.dirname(__file__), f'access/{data['id']}.json')) as f:
report_access = json.load(f)
if session['role'] in report_access['write']:
proc_name = report_access['procedure']
if session['role'] in report_list[id]['data']['write']:
proc_name = report_list[id]['data']['procedure']
ready_report = make_report(data, proc_name)
if ready_report.status:
return render_template("OK.html")
@@ -53,17 +51,15 @@ def view():
items=report_list,
date_today=date.today())
else:
data = dict(id=request.form.get('category'),
month=request.form.get('month'),
year=request.form.get('year'))
with open(path.join(path.dirname(__file__), f'access/{data['id']}.json')) as f:
report_access = json.load(f)
id = request.form.get('category')
month = request.form.get('month')
year = request.form.get('year')
data = dict(id=id, month=month, year=year)
if session['role'] in report_access['read']:
ready_report = view_report(data, report_access['view'])
if session['role'] in report_list[id]['data']['read']:
ready_report = view_report(data, report_list[id]['data']['view'])
if ready_report.status:
title= f'{report_access["title"]} за {data["month"]}-{data["year"]}'
title= f'{report_list[id]['data']['title']} за {data["month"]}-{data["year"]}'
return render_template("output.html", items=ready_report.result,
header=title,
link = url_for('report_bp.menu'))