Даты как параметры + страница для ошибок

This commit is contained in:
Anton Kamalov
2024-10-24 20:35:06 +03:00
parent e1d0510669
commit e97300f860
4 changed files with 23 additions and 12 deletions

View File

@@ -3,6 +3,7 @@ from os import path
from Database.sql_provider import SQLProvider
from checker import check_auth
from .requests_route import route
from datetime import date
import json
with open(path.join(path.dirname(__file__), 'zapros_menu.json')) as f:
@@ -16,8 +17,6 @@ requests_bp = Blueprint('requests_bp', __name__, template_folder='templates')
def requests():
if request.method == 'GET':
return render_template('zapros_menu.html', options=requests_list)
else:
return 'error'
@requests_bp.route('/req1', methods=['GET', 'POST'])
@check_auth
@@ -27,7 +26,7 @@ def sklad_zapros():
if zagotovki.status:
return render_template('sklad_zapros.html', materials=zagotovki.result)
else:
return zagotovki.error_message
return render_template('error.html', error_message=zagotovki.error_message)
else:
material = dict(request.form)
zagotovki = route(session['db_config'], material, sql_provider, 'zapros1.sql')
@@ -35,7 +34,7 @@ def sklad_zapros():
header = f'Заготовки на складе из материала \'{material["material"]}\''
return render_template('output.html', items=zagotovki.result, object=header)
else:
return zagotovki.error_message
return render_template('error.html', error_message=zagotovki.error_message)
@requests_bp.route('/req2', methods=['GET', 'POST'])
@check_auth
@@ -43,15 +42,16 @@ def zagotovki_ship():
if request.method == 'GET':
zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql')
if zagotovki.status:
return render_template('zagotovki_ship.html', materials=zagotovki.result)
date_from = '2000-01-01'
date_to = date.today().strftime('%Y-%m-%d')
return render_template('zagotovki_ship.html', materials=zagotovki.result, date_from=date_from, date_to=date_to)
else:
return zagotovki.error_message
return render_template('error.html', error_message=zagotovki.error_message)
else:
material = dict(request.form)
print(material)
zagotovki = route(session['db_config'], material, sql_provider, 'zapros2.sql')
if zagotovki.status:
header = f'Поставленные заготовки из материала \'{material["material"]}\''
return render_template('output.html', items=zagotovki.result, object=header)
else:
return zagotovki.error_message
return render_template('error.html', error_message=zagotovki.error_message)