From 8caa72d2fdd7f6c00f7fa88f776453aa9baa2bed Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 12:14:14 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B2=D0=BE=D0=B4=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=BA=20MVC=20+=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0?= =?UTF-8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=BA=D0=B8=20(=D0=B2=20=D0=BE=D1=81=D0=BD?= =?UTF-8?q?=D0=BE=D0=B2=D0=BD=D0=BE=D0=BC=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE?= =?UTF-8?q?=D0=B6=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=B8=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D0=B0=D1=85)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/__init__.py | 14 +++++--------- App/Requests/requests_model.py | 11 ++++++----- App/Requests/templates/sellers_ship.html | 8 +++++--- App/app.py | 6 +++--- 4 files changed, 19 insertions(+), 20 deletions(-) diff --git a/App/Requests/__init__.py b/App/Requests/__init__.py index c3d0b8b..74fc5be 100644 --- a/App/Requests/__init__.py +++ b/App/Requests/__init__.py @@ -4,7 +4,7 @@ from checker import check_auth from .requests_model import sklad, materials_per_seller, sellers_names, materials_names import json -with open(path.join(path.dirname(__file__), 'zapros_menu.json')) as f: +with open(path.join(path.dirname(__file__), 'zapros_menu.json'), encoding='utf-8') as f: requests_list = json.load(f) requests_bp = Blueprint('requests_bp', __name__, template_folder='templates') @@ -19,11 +19,9 @@ def requests(): @check_auth def sklad_zapros(): if request.method == 'GET': - materials = materials_names() - return render_template('zagotovki.html', materials=materials.result) + return render_template('zagotovki.html') else: - material = dict(request.form) - zagotovki = sklad(material) + zagotovki = sklad(request) if zagotovki.status: header = f'Заготовки на складе из материала \"{material["material"]}\"' return render_template('output.html', items=zagotovki.result, header=header) @@ -34,11 +32,9 @@ def sklad_zapros(): @check_auth def sellers_ship(): if request.method == 'GET': - sellers = sellers_names() - return render_template('sellers_ship.html', sellers=sellers.result) + return render_template('sellers_ship.html') else: - seller = dict(request.form) - zagotovki = materials_per_seller(seller) + zagotovki = materials_per_seller(request) if zagotovki.status: header = f'Поставки от поставщика \"{seller["seller"]}\"' return render_template('output.html', items=zagotovki.result, header=header, link=url_for('requests_bp.requests')) diff --git a/App/Requests/requests_model.py b/App/Requests/requests_model.py index f19df13..3841ef7 100644 --- a/App/Requests/requests_model.py +++ b/App/Requests/requests_model.py @@ -29,9 +29,9 @@ def materials_names() -> InfoRespronse: status=False) return InfoRespronse(result, error_message='', status=True) -def sklad(input_data) -> InfoRespronse: - _sql = sql_provider.get('sklad_material.sql', input_data) - print("sql = ", _sql) +def sklad(request) -> InfoRespronse: + material = dict(request.form) + _sql = sql_provider.get('sklad_material.sql', material) result = select_list(current_app.config['db_config'], _sql) if result is None: return InfoRespronse((), @@ -40,8 +40,9 @@ def sklad(input_data) -> InfoRespronse: return InfoRespronse(result, error_message='', status=True) -def materials_per_seller(input_data) -> InfoRespronse: - _sql = sql_provider.get('ship_seller.sql', input_data) +def materials_per_seller(request) -> InfoRespronse: + seller = dict(request.form) + _sql = sql_provider.get('ship_seller.sql', seller) result = select_list(current_app.config['db_config'], _sql) if result is None: return InfoRespronse((), diff --git a/App/Requests/templates/sellers_ship.html b/App/Requests/templates/sellers_ship.html index 0ef90df..844a8f6 100644 --- a/App/Requests/templates/sellers_ship.html +++ b/App/Requests/templates/sellers_ship.html @@ -33,9 +33,11 @@
diff --git a/App/app.py b/App/app.py index fe5e3d3..7f96e0e 100644 --- a/App/app.py +++ b/App/app.py @@ -9,9 +9,9 @@ app = Flask(__name__) app.secret_key = 'suplex' app.config.update( - db_config=json.load(open(os.path.join(os.path.dirname(__file__), 'data/config.json'))), - db_access=json.load(open(os.path.join(os.path.dirname(__file__), 'data/db_access.json'))), - cache_config=json.load(open(os.path.join(os.path.dirname(__file__), 'data/redis_config.json'))) + db_config=json.load(open(os.path.join(os.path.dirname(__file__), 'data/config.json'), encoding='utf-8')), + db_access=json.load(open(os.path.join(os.path.dirname(__file__), 'data/db_access.json'), encoding='utf-8')), + cache_config=json.load(open(os.path.join(os.path.dirname(__file__), 'data/redis_config.json'), encoding='utf-8')) ) app.register_blueprint(requests_bp, url_prefix='/requests')