pre-commit changes

This commit is contained in:
2024-12-08 12:17:19 +03:00
parent 2852ce1f96
commit 87e9029b09
15 changed files with 400 additions and 293 deletions

View File

@@ -1,27 +1,33 @@
from flask import request, Blueprint, render_template, url_for
from checker import check_auth
from os import path
from datetime import date
from .report_model import view_report_model, create_report_model
import json
from datetime import date
from os import path
with open(path.join(path.dirname(__file__), 'reports.json'), encoding='utf-8') as f:
from checker import check_auth
from flask import Blueprint, render_template, request, url_for
from .report_model import create_report_model, view_report_model
with open(path.join(path.dirname(__file__), "reports.json"), encoding="utf-8") as f:
report_list = json.load(f)
report_bp = Blueprint('report_bp', __name__, template_folder='templates', static_folder='static')
report_bp = Blueprint(
"report_bp", __name__, template_folder="templates", static_folder="static"
)
@report_bp.route('/menu')
@report_bp.route("/menu")
@check_auth
def menu():
if request.method == 'GET':
return render_template('report_menu.html')
if request.method == "GET":
return render_template("report_menu.html")
# Рекомендации от ИС
# @report_bp.route('/test', methods=['GET'])
# def get_test():
# return render_template('report_basic.html',
# is_write=True,
# title='Создание отчетов',
# return render_template('report_basic.html',
# is_write=True,
# title='Создание отчетов',
# items=report_list,
# date_today=date.today())
@@ -29,16 +35,19 @@ def menu():
# def post_test():
# report_response = model(request, report_list)
# return view(report_response)
@report_bp.route('/create', methods=['GET', 'POST'])
@report_bp.route("/create", methods=["GET", "POST"])
@check_auth
def create():
if request.method == 'GET':
return render_template('report_basic.html',
is_write=True,
title='Создание отчетов',
items=report_list,
date_today=date.today())
if request.method == "GET":
return render_template(
"report_basic.html",
is_write=True,
title="Создание отчетов",
items=report_list,
date_today=date.today(),
)
else:
result = create_report_model(request, report_list)
if result.status:
@@ -46,20 +55,26 @@ def create():
else:
return render_template("error.html", error_message=result.error_message)
@report_bp.route('/view', methods=['GET', 'POST'])
@report_bp.route("/view", methods=["GET", "POST"])
@check_auth
def view():
if request.method == 'GET':
return render_template('report_basic.html',
is_write=False,
title='Просмотр отчетов',
items=report_list,
date_today=date.today())
if request.method == "GET":
return render_template(
"report_basic.html",
is_write=False,
title="Просмотр отчетов",
items=report_list,
date_today=date.today(),
)
else:
result = view_report_model(request, report_list)
if result.status:
return render_template("output.html", items=result.result,
header='Результаты отчёта',
link = url_for('report_bp.menu'))
return render_template(
"output.html",
items=result.result,
header="Результаты отчёта",
link=url_for("report_bp.menu"),
)
else:
return render_template("error.html", error_message=result.error_message)
return render_template("error.html", error_message=result.error_message)