Универсальная функция просмотра отчётов
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from flask import request, Blueprint, render_template, session, url_for
|
from flask import request, Blueprint, render_template, session, url_for
|
||||||
from checker import check_auth
|
from checker import check_auth
|
||||||
from os import path
|
from os import path
|
||||||
from .report_model import sales_report, make_report
|
from .report_model import view_report, make_report
|
||||||
import json
|
import json
|
||||||
|
|
||||||
with open(path.join(path.dirname(__file__), 'reports.json')) as f:
|
with open(path.join(path.dirname(__file__), 'reports.json')) as f:
|
||||||
@@ -56,7 +56,7 @@ def view():
|
|||||||
report_access = json.load(f)
|
report_access = json.load(f)
|
||||||
|
|
||||||
if session['role'] in report_access['read']:
|
if session['role'] in report_access['read']:
|
||||||
ready_report = sales_report(data, report_access['view'])
|
ready_report = view_report(data, report_access['view'])
|
||||||
if ready_report.status:
|
if ready_report.status:
|
||||||
title= f'{report_access["title"]} за {data["month"]}-{data["year"]}'
|
title= f'{report_access["title"]} за {data["month"]}-{data["year"]}'
|
||||||
return render_template("output.html", items=ready_report.result,
|
return render_template("output.html", items=ready_report.result,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ def check_report(input_data: dict) -> bool:
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def sales_report(input_data: dict, view_script: str) -> InfoRespronse:
|
def view_report(input_data: dict, view_script: str) -> InfoRespronse:
|
||||||
status = check_report(input_data)
|
status = check_report(input_data)
|
||||||
if not status:
|
if not status:
|
||||||
return InfoRespronse((),
|
return InfoRespronse((),
|
||||||
|
|||||||
Reference in New Issue
Block a user