From e97300f860c5394135907bb99fe775464d7143c7 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 24 Oct 2024 20:35:06 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=B0=D1=82=D1=8B=20=D0=BA=D0=B0=D0=BA?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D0=B0=D0=BC=D0=B5=D1=82=D1=80=D1=8B=20+?= =?UTF-8?q?=20=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D0=B0=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/requests.py | 16 ++++++++-------- App/Requests/templates/error.html | 13 +++++++++++++ App/Requests/templates/zagotovki_ship.html | 4 ++-- App/app.py | 2 -- 4 files changed, 23 insertions(+), 12 deletions(-) create mode 100644 App/Requests/templates/error.html 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'