Динамическое получение списка материалов и поставщиков
This commit is contained in:
@@ -24,7 +24,8 @@ def requests():
|
||||
@check_auth
|
||||
def sklad_zapros():
|
||||
if request.method == "GET":
|
||||
return render_template("zagotovki.html")
|
||||
materials = materials_names()
|
||||
return render_template("zagotovki.html", materials=materials)
|
||||
else:
|
||||
zagotovki = sklad(request)
|
||||
if zagotovki.status:
|
||||
@@ -39,7 +40,8 @@ def sklad_zapros():
|
||||
@check_auth
|
||||
def sellers_ship():
|
||||
if request.method == "GET":
|
||||
return render_template("sellers_ship.html")
|
||||
sellers = sellers_names()
|
||||
return render_template("sellers_ship.html", sellers=sellers)
|
||||
else:
|
||||
zagotovki = materials_per_seller(request)
|
||||
if zagotovki.status:
|
||||
|
||||
@@ -15,31 +15,19 @@ class InfoRespronse:
|
||||
status: bool
|
||||
|
||||
|
||||
def sellers_names() -> InfoRespronse:
|
||||
def sellers_names() -> list:
|
||||
db_config = current_app.config["db_config"]
|
||||
|
||||
_sql = sql_provider.get("sellers_names.sql", {})
|
||||
result = select_list(db_config, _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(
|
||||
(),
|
||||
error_message="Ошибка в подключении к базе данных. Свяжитесь с администратором",
|
||||
status=False,
|
||||
)
|
||||
return InfoRespronse(result, error_message="", status=True)
|
||||
|
||||
|
||||
def materials_names() -> InfoRespronse:
|
||||
def materials_names() -> list:
|
||||
db_config = current_app.config["db_config"]
|
||||
|
||||
_sql = sql_provider.get("materials_names.sql", {})
|
||||
result = select_list(db_config, _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(
|
||||
(),
|
||||
error_message="Ошибка в подключении к базе данных. Свяжитесь с администратором",
|
||||
status=False,
|
||||
)
|
||||
return InfoRespronse(result, error_message="", status=True)
|
||||
|
||||
|
||||
@@ -49,12 +37,6 @@ def sklad(request) -> InfoRespronse:
|
||||
|
||||
_sql = sql_provider.get("sklad_material.sql", material)
|
||||
result = select_list(db_config, _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(
|
||||
(),
|
||||
error_message="Ошибка в подключении к базе данных. Свяжитесь с администратором",
|
||||
status=False,
|
||||
)
|
||||
return InfoRespronse(result, error_message="", status=True)
|
||||
|
||||
|
||||
@@ -64,10 +46,4 @@ def materials_per_seller(request) -> InfoRespronse:
|
||||
seller = dict(request.form)
|
||||
_sql = sql_provider.get("ship_seller.sql", seller)
|
||||
result = select_list(db_config, _sql)
|
||||
if result is None:
|
||||
return InfoRespronse(
|
||||
(),
|
||||
error_message="Ошибка в подключении к базе данных. Свяжитесь с администратором",
|
||||
status=False,
|
||||
)
|
||||
return InfoRespronse(result, error_message="", status=True)
|
||||
|
||||
@@ -33,11 +33,9 @@
|
||||
<form action="" method="post" style="display: inline-block;">
|
||||
<label>Выберите поставщика</label>
|
||||
<select class="form-select" name="seller">
|
||||
<option value="Alpha Supplies">Alpha Supplies</option>
|
||||
<option value="Beta Materials">Beta Materials</option>
|
||||
<option value="Gamma Parts">Gamma Parts</option>
|
||||
<option value="Delta Components">Delta Components</option>
|
||||
<option value="Epsilon Goods">Epsilon Goods</option>
|
||||
{% for item in sellers %}
|
||||
<option value="{{ item["name"] }}">{{ item["name"] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary">Отправить</button>
|
||||
</form>
|
||||
|
||||
@@ -34,11 +34,9 @@
|
||||
<form action="" method="post" style="display: inline-block;">
|
||||
<label>Выберите материал</label>
|
||||
<select class="form-select" name="material">
|
||||
<option value="Сталь">Сталь</option>
|
||||
<option value="Алюминий">Алюминий</option>
|
||||
<option value="Медь">Медь</option>
|
||||
<option value="Пластик">Пластик</option>
|
||||
<option value="Дерево">Дерево</option>
|
||||
{% for item in materials %}
|
||||
<option value="{{ item["name"] }}">{{ item["name"] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary">Отправить</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user