Перемещение части специфичных шаблонов в общую папку

This commit is contained in:
2024-11-14 15:09:53 +03:00
parent c11283f074
commit cde558d278
4 changed files with 27 additions and 38 deletions

View File

@@ -1,8 +1,7 @@
from flask import request, Blueprint, render_template
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 datetime import date
import json
with open(path.join(path.dirname(__file__), 'zapros_menu.json')) as f:
@@ -14,7 +13,7 @@ requests_bp = Blueprint('requests_bp', __name__, template_folder='templates')
@check_auth
def requests():
if request.method == 'GET':
return render_template('zapros_menu.html', options=requests_list)
return render_template('pages_menu.html', options=requests_list, header='Запросы')
@requests_bp.route('/sklad', methods=['GET', 'POST'])
@check_auth
@@ -30,25 +29,6 @@ def sklad_zapros():
return render_template('output.html', items=zagotovki.result, header=header)
else:
return render_template('error.html', error_message=zagotovki.error_message)
# Под вопросом
""" @requests_bp.route('/req2', methods=['GET', 'POST'])
@check_auth
def zagotovki_ship():
if request.method == 'GET':
zagotovki = get_goods()
if zagotovki.status:
return render_template('zagotovki.html', materials=zagotovki.result, header='Поставки заготовок')
else:
return render_template('error.html', error_message=zagotovki.error_message)
else:
material = dict(request.form)
zagotovki = route(material, 'zapros2.sql')
if zagotovki.status:
header = f'Поставки заготовок из материала \'{material['material']}\''
return render_template('output.html', items=zagotovki.result, object=header)
else:
return render_template('error.html', error_message=zagotovki.error_message) """
@requests_bp.route('/shipments', methods=['GET', 'POST'])
@check_auth
@@ -61,6 +41,6 @@ def sellers_ship():
zagotovki = materials_per_seller(seller)
if zagotovki.status:
header = f'Поставки от поставщика \"{seller["seller"]}\"'
return render_template('output.html', items=zagotovki.result, header=header)
return render_template('output.html', items=zagotovki.result, header=header, link=url_for('requests_bp.requests'))
else:
return render_template('error.html', error_message=zagotovki.error_message)

View File

@@ -1,13 +0,0 @@
<!DOCTYPE html>
<html lang="ru">
<head>
<meta charset="UTF-8">
<title>Ошибка</title>
<link href="/static/css/main.css" type="text/css" rel="stylesheet">
</head>
<body>
<h1>Произошла ошибка</h1>
<p>{{ error_message }}.</p>
<a href="{{ url_for('index') }}"><button>На главную страницу</button></a>
</body>
</html>

View File

@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="ru">
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ header }}</title>
@@ -31,6 +31,6 @@
<p>Информации не найдено</p>
{% endif %}
<div class="return">
<a href="{{ url_for('requests_bp.requests') }}"><button>Обратно в меню запросов</button></a>
<a href="{{ link }}"><button>Вернуться в меню выбора</button></a>
</div></body>
</html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ header }}</title>
<link href="/static/css/main.css" type="text/css" rel="stylesheet">
</head>
<body>
<div class="logout">
<a href="{{ url_for('logout') }}"><button>Выход</button></a>
</div>
<h1>Выберите один из предложенных вариантов</h1>
<nav class="menu">
{% for point in options %}
<a href="{{ url_for(point['url']) }}"><button>{{ point['name'] }}</button></a>
{% endfor %}
</nav>
<div class="return">
<a href="{{ url_for('index') }}"><button>Главное меню</button></a>
</div>
</body>
</html>