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 }}

+

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

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