Запрос №3

This commit is contained in:
Anton Kamalov
2024-10-24 23:30:57 +03:00
parent 42720af4e2
commit 341c41489c
5 changed files with 38 additions and 10 deletions

View File

@@ -24,7 +24,7 @@ def sklad_zapros():
if request.method == 'GET':
zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql')
if zagotovki.status:
return render_template('sklad_zapros.html', materials=zagotovki.result)
return render_template('zagotovki.html', materials=zagotovki.result, header='Количество заготовок на складе')
else:
return render_template('error.html', error_message=zagotovki.error_message)
else:
@@ -38,13 +38,13 @@ def sklad_zapros():
@requests_bp.route('/req2', methods=['GET', 'POST'])
@check_auth
def zagotovki_ship():
def sellers_ship():
if request.method == 'GET':
zagotovki = route(session['db_config'], {}, sql_provider, 'sellers.sql')
if zagotovki.status:
min_year = '2000'
max_year = str(date.today().year)
return render_template('zagotovki_ship.html', sellers=zagotovki.result, year_from=min_year, year_to=max_year)
return render_template('sellers_ship.html', sellers=zagotovki.result, year_from=min_year, year_to=max_year)
else:
return render_template('error.html', error_message=zagotovki.error_message)
else:
@@ -53,5 +53,23 @@ def zagotovki_ship():
if zagotovki.status:
header = f'Заготовки, поставленные поставщиком \'{seller['seller']}\''
return render_template('output.html', items=zagotovki.result, object=header)
else:
return render_template('error.html', error_message=zagotovki.error_message)
@requests_bp.route('/req3', methods=['GET', 'POST'])
@check_auth
def zagotovki_ship():
if request.method == 'GET':
zagotovki = route(session['db_config'], {}, sql_provider, 'zagotovki.sql')
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(session['db_config'], material, sql_provider, 'zapros3.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)