diff --git a/App/Requests/requests.py b/App/Requests/requests.py index 3370991..7576d2c 100644 --- a/App/Requests/requests.py +++ b/App/Requests/requests.py @@ -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 \ No newline at end of file + return render_template('error.html', error_message=zagotovki.error_message) \ No newline at end of file diff --git a/App/Requests/templates/error.html b/App/Requests/templates/error.html new file mode 100644 index 0000000..c1a8828 --- /dev/null +++ b/App/Requests/templates/error.html @@ -0,0 +1,13 @@ + + + + + Ошибка + + + +

Произошла ошибка

+

{{ error_message }}.

+ + + diff --git a/App/Requests/templates/zagotovki_ship.html b/App/Requests/templates/zagotovki_ship.html index 91d3b17..5e48411 100644 --- a/App/Requests/templates/zagotovki_ship.html +++ b/App/Requests/templates/zagotovki_ship.html @@ -19,8 +19,8 @@ {% endfor %}

Выберите даты:

-

с

-

по

+

с

+

по

diff --git a/App/app.py b/App/app.py index da1a9dd..b5cd26c 100644 --- a/App/app.py +++ b/App/app.py @@ -1,9 +1,7 @@ from flask import Flask, render_template, session from Requests.requests import requests_bp from Auth.auth import auth_bp -from os import path from checker import check_auth -import json app = Flask(__name__) app.secret_key = 'suplex'