From e522666f401f3ac606edc02c47ffafdac5f8a2f2 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 14 Nov 2024 21:19:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B8=D0=BD=D0=B0=D0=BC=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D0=BA=D0=BE=D0=B5=20=D0=BF=D0=BE=D0=BB=D1=83=D1=87?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B0?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=D0=BA=20?= =?UTF-8?q?=D0=B8=20=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/__init__.py | 10 +++++----- App/Requests/requests_model.py | 19 +++++++++++++++++++ App/Requests/sql/materials_names.sql | 1 + App/Requests/sql/sellers_names.sql | 1 + App/Requests/templates/sellers_ship.html | 8 +++----- App/Requests/templates/zagotovki.html | 4 ++-- 6 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 App/Requests/sql/materials_names.sql create mode 100644 App/Requests/sql/sellers_names.sql diff --git a/App/Requests/__init__.py b/App/Requests/__init__.py index c162543..2dd42d4 100644 --- a/App/Requests/__init__.py +++ b/App/Requests/__init__.py @@ -1,7 +1,7 @@ from flask import request, Blueprint, render_template, url_for from os import path from checker import check_auth -from .requests_model import sklad, materials_per_seller +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: @@ -19,8 +19,8 @@ def requests(): @check_auth def sklad_zapros(): if request.method == 'GET': - # materials = ['Сталь', 'Алюминий', 'Медь', 'Пластик', 'Дерево'] - return render_template('zagotovki.html', header='Количество заготовок на складе') + materials = materials_names() + return render_template('zagotovki.html', materials=materials.result) else: material = dict(request.form) zagotovki = sklad(material) @@ -34,8 +34,8 @@ def sklad_zapros(): @check_auth def sellers_ship(): if request.method == 'GET': - # sellers = ['Alpha Supplies', 'Beta Materials', 'Gamma Parts', 'Delta Components', 'Epsilon Goods'] - return render_template('sellers_ship.html') + sellers = sellers_names() + return render_template('sellers_ship.html', sellers=sellers.result) else: seller = dict(request.form) zagotovki = materials_per_seller(seller) diff --git a/App/Requests/requests_model.py b/App/Requests/requests_model.py index f1443f6..f19df13 100644 --- a/App/Requests/requests_model.py +++ b/App/Requests/requests_model.py @@ -11,6 +11,24 @@ class InfoRespronse: error_message: str status: bool +def sellers_names() -> InfoRespronse: + _sql = sql_provider.get('sellers_names.sql', {}) + result = select_list(current_app.config['db_config'], _sql) + if result is None: + return InfoRespronse((), + error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', + status=False) + return InfoRespronse(result, error_message='', status=True) + +def materials_names() -> InfoRespronse: + _sql = sql_provider.get('materials_names.sql', {}) + result = select_list(current_app.config['db_config'], _sql) + if result is None: + return InfoRespronse((), + error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', + 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) @@ -21,6 +39,7 @@ def sklad(input_data) -> InfoRespronse: status=False) return InfoRespronse(result, error_message='', status=True) + def materials_per_seller(input_data) -> InfoRespronse: _sql = sql_provider.get('ship_seller.sql', input_data) result = select_list(current_app.config['db_config'], _sql) diff --git a/App/Requests/sql/materials_names.sql b/App/Requests/sql/materials_names.sql new file mode 100644 index 0000000..e5873a7 --- /dev/null +++ b/App/Requests/sql/materials_names.sql @@ -0,0 +1 @@ +SELECT DISTINCT material FROM workpiece; \ No newline at end of file diff --git a/App/Requests/sql/sellers_names.sql b/App/Requests/sql/sellers_names.sql new file mode 100644 index 0000000..be9f77c --- /dev/null +++ b/App/Requests/sql/sellers_names.sql @@ -0,0 +1 @@ +SELECT name FROM sellers; \ No newline at end of file diff --git a/App/Requests/templates/sellers_ship.html b/App/Requests/templates/sellers_ship.html index c14c1a8..629f9fc 100644 --- a/App/Requests/templates/sellers_ship.html +++ b/App/Requests/templates/sellers_ship.html @@ -15,11 +15,9 @@

Выберите поставщика

diff --git a/App/Requests/templates/zagotovki.html b/App/Requests/templates/zagotovki.html index 9d2de58..fab9e65 100644 --- a/App/Requests/templates/zagotovki.html +++ b/App/Requests/templates/zagotovki.html @@ -2,7 +2,7 @@ - {{ header }} + Количество заготовок на складе @@ -10,7 +10,7 @@ -

{{ header }}

+

Количество заготовок на складе

Выберите материал