From b5cd97d38c34227643e0f218ece5a760350b0db3 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 6 Nov 2024 01:08:21 +0300 Subject: [PATCH 01/33] RIS in Docker --- Dockerfile | 18 ++++++++++++++++++ requirements.txt | 3 +++ start.sh | 4 ++++ 3 files changed, 25 insertions(+) create mode 100644 Dockerfile create mode 100644 requirements.txt create mode 100755 start.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..956acce --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Use the official Python image as a base +FROM python:3.9.20-alpine3.19 + +# Set the working directory inside the container +WORKDIR /app + +# Copy the contents of the 'App' folder to the working directory +COPY App/ /app + +# Copy the requirements file to the working directory +COPY requirements.txt /app + +# Install the dependencies from the requirements file +RUN pip install --no-cache-dir -r requirements.txt + +EXPOSE 5001 +# Command to run the application +CMD ["python", "app.py"] diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..5684634 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +cryptography==43.0.3 +Flask==3.0.3 +PyMySQL==1.1.1 diff --git a/start.sh b/start.sh new file mode 100755 index 0000000..19b19c4 --- /dev/null +++ b/start.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t ris:latest . +docker run -d -p 5001:5001 ris From fa536c6f396a879136efe0596d5f40920bc0ec7a Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 6 Nov 2024 23:15:51 +0300 Subject: [PATCH 02/33] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= =?UTF-8?q?=20=D1=81=20=D0=BF=D0=BE=D1=81=D1=82=D0=B0=D0=B2=D1=89=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/__init__.py | 10 +++++----- App/Requests/sql/zapros3.sql | 1 - App/Requests/templates/sellers_ship.html | 6 ++---- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/App/Requests/__init__.py b/App/Requests/__init__.py index 2203627..c2a07e6 100644 --- a/App/Requests/__init__.py +++ b/App/Requests/__init__.py @@ -20,13 +20,13 @@ def requests(): @check_auth def sklad_zapros(): if request.method == 'GET': - materials = ['Сталь', 'Золото', 'Дерево', 'Стекло', 'Медь', 'Цемент'] + materials = ['Сталь', 'Алюминий', 'Медь', 'Пластик', 'Дерево'] return render_template('zagotovki.html', materials=materials, header='Количество заготовок на складе') else: material = dict(request.form) zagotovki = sklad(material) if zagotovki.status: - header = f'Заготовки на складе из материала \'{material["material"]}\'' + 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) @@ -54,13 +54,13 @@ def zagotovki_ship(): @check_auth def sellers_ship(): if request.method == 'GET': - sellers = ['Car and bikes', 'Doto', 'LPD', 'Neva', 'PGG', 'Robot', 'Rost'] - return render_template('sellers_ship.html', sellers=sellers, year_from='2000', year_to=str(date.today().year)) + sellers = ['Alpha Supplies', 'Beta Materials', 'Gamma Parts', 'Delta Components', 'Epsilon Goods'] + return render_template('sellers_ship.html', sellers=sellers) else: seller = dict(request.form) zagotovki = materials_per_seller(seller) if zagotovki.status: - header = f'Поставки от поставщика \'{seller['seller']}\'' + 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) \ No newline at end of file diff --git a/App/Requests/sql/zapros3.sql b/App/Requests/sql/zapros3.sql index 7336117..582b34f 100644 --- a/App/Requests/sql/zapros3.sql +++ b/App/Requests/sql/zapros3.sql @@ -5,5 +5,4 @@ FROM waybill w JOIN (SELECT waybill_id, SUM(count) AS cnt FROM waybill_lines wl GROUP BY waybill_id)wl USING (waybill_id) JOIN sellers USING(sel_id) WHERE sellers.name = '${seller}' -AND YEAR(date_of_delivery) = '${date}' GROUP BY date_of_delivery \ No newline at end of file diff --git a/App/Requests/templates/sellers_ship.html b/App/Requests/templates/sellers_ship.html index 8a14679..afc6eea 100644 --- a/App/Requests/templates/sellers_ship.html +++ b/App/Requests/templates/sellers_ship.html @@ -2,7 +2,7 @@ - Поставки поставщиком за год + Все поставки поставщиком @@ -10,7 +10,7 @@ -

Поставки поставщиком за год

+

Все поставки поставщиком

Выберите поставщика

@@ -19,8 +19,6 @@ {% endfor %} -

Выберите год:

-

From 7e39763d771824d0609219b04d82600078020437 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 6 Nov 2024 23:16:10 +0300 Subject: [PATCH 03/33] =?UTF-8?q?=D0=94=D0=BB=D1=8F=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=BD=D0=B0=20=D0=B4=D1=80?= =?UTF-8?q?=D1=83=D0=B3=D0=B8=D1=85=20=D1=83=D1=81=D1=82=D1=80=D0=BE=D0=B9?= =?UTF-8?q?=D1=81=D1=82=D0=B2=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/App/app.py b/App/app.py index b718a1e..4b49c69 100644 --- a/App/app.py +++ b/App/app.py @@ -26,4 +26,4 @@ def index(): def logout(): session.clear() return render_template('main_menu.html', ses=session) -app.run(port=5001, debug=True) \ No newline at end of file +app.run(port=5001, host='0.0.0.0') \ No newline at end of file From e76b26c6d617460f6de9b9874c5ead7c4584c780 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 6 Nov 2024 23:32:04 +0300 Subject: [PATCH 04/33] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D0=BA=D0=B0=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=D0=B0?= =?UTF-8?q?=20=D0=B4=D0=BB=D1=8F=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B5=D0=B9?= =?UTF-8?q?=D0=BD=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.sh | 4 ++++ start.sh | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) create mode 100755 build.sh delete mode 100755 start.sh diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..5fe7bd9 --- /dev/null +++ b/build.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +docker build -t tsettaro/kursovaya-ris:latest . +docker push tsettaro/kursovaya-ris:latest diff --git a/start.sh b/start.sh deleted file mode 100755 index 19b19c4..0000000 --- a/start.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -docker build -t ris:latest . -docker run -d -p 5001:5001 ris From 200116f6f40c5032647de6eb55a9376444f47338 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 7 Nov 2024 10:50:14 +0300 Subject: [PATCH 05/33] =?UTF-8?q?=D0=92=D1=8B=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20Docker=20=D0=B2=20=D0=BE=D1=82=D0=B4=D0=B5?= =?UTF-8?q?=D0=BB=D1=8C=D0=BD=D1=83=D1=8E=20=D0=B2=D0=B5=D1=82=D0=B2=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 18 ------------------ build.sh | 4 ---- 2 files changed, 22 deletions(-) delete mode 100644 Dockerfile delete mode 100755 build.sh diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 956acce..0000000 --- a/Dockerfile +++ /dev/null @@ -1,18 +0,0 @@ -# Use the official Python image as a base -FROM python:3.9.20-alpine3.19 - -# Set the working directory inside the container -WORKDIR /app - -# Copy the contents of the 'App' folder to the working directory -COPY App/ /app - -# Copy the requirements file to the working directory -COPY requirements.txt /app - -# Install the dependencies from the requirements file -RUN pip install --no-cache-dir -r requirements.txt - -EXPOSE 5001 -# Command to run the application -CMD ["python", "app.py"] diff --git a/build.sh b/build.sh deleted file mode 100755 index 5fe7bd9..0000000 --- a/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -docker build -t tsettaro/kursovaya-ris:latest . -docker push tsettaro/kursovaya-ris:latest From 7c5166561761dc4fff718d4a97067d873f580b73 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 7 Nov 2024 14:43:58 +0300 Subject: [PATCH 06/33] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B7=D0=B0=20=D0=B7=D0=B0=D0=B3=D0=BE=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=B2=D0=BA=D0=BB=D0=B0=D0=B4=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/__init__.py | 4 ++-- App/Requests/templates/output.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/App/Requests/__init__.py b/App/Requests/__init__.py index c2a07e6..879897f 100644 --- a/App/Requests/__init__.py +++ b/App/Requests/__init__.py @@ -27,7 +27,7 @@ def sklad_zapros(): zagotovki = sklad(material) if zagotovki.status: header = f'Заготовки на складе из материала \"{material["material"]}\"' - return render_template('output.html', items=zagotovki.result, object=header) + return render_template('output.html', items=zagotovki.result, header=header) else: return render_template('error.html', error_message=zagotovki.error_message) @@ -61,6 +61,6 @@ def sellers_ship(): zagotovki = materials_per_seller(seller) if zagotovki.status: header = f'Поставки от поставщика \"{seller["seller"]}\"' - return render_template('output.html', items=zagotovki.result, object=header) + return render_template('output.html', items=zagotovki.result, header=header) else: return render_template('error.html', error_message=zagotovki.error_message) \ No newline at end of file diff --git a/App/Requests/templates/output.html b/App/Requests/templates/output.html index de25cbc..e632081 100644 --- a/App/Requests/templates/output.html +++ b/App/Requests/templates/output.html @@ -2,7 +2,7 @@ - {{ object }} + {{ header }} @@ -10,7 +10,7 @@ -

{{ object }}

+

{{ header }}

{% if items %} From f0f88f28c5446e06eb38c0090685781e3b6dc74b Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 7 Nov 2024 14:52:21 +0300 Subject: [PATCH 07/33] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B8=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=84=D0=B0?= =?UTF-8?q?=D0=B9=D0=BB=D0=BE=D0=B2=20=D1=81=20sql-=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/requests_model.py | 4 ++-- App/Requests/sql/{zapros3.sql => ship_seller.sql} | 0 App/Requests/sql/{zapros1.sql => sklad_material.sql} | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename App/Requests/sql/{zapros3.sql => ship_seller.sql} (100%) rename App/Requests/sql/{zapros1.sql => sklad_material.sql} (100%) diff --git a/App/Requests/requests_model.py b/App/Requests/requests_model.py index 33378a9..69fc110 100644 --- a/App/Requests/requests_model.py +++ b/App/Requests/requests_model.py @@ -12,7 +12,7 @@ class InfoRespronse: status: bool def sklad(input_data) -> InfoRespronse: - _sql = sql_provider.get('zapros1.sql', input_data) + _sql = sql_provider.get('sklad_material.sql', input_data) print("sql = ", _sql) result = select_list(current_app.config['db_config'], _sql) if result is None: @@ -22,7 +22,7 @@ def sklad(input_data) -> InfoRespronse: return InfoRespronse(result, error_message='', status=True) def materials_per_seller(input_data) -> InfoRespronse: - _sql = sql_provider.get('zapros3.sql', input_data) + _sql = sql_provider.get('ship_seller.sql', input_data) result = select_list(current_app.config['db_config'], _sql) if result is None: return InfoRespronse((), diff --git a/App/Requests/sql/zapros3.sql b/App/Requests/sql/ship_seller.sql similarity index 100% rename from App/Requests/sql/zapros3.sql rename to App/Requests/sql/ship_seller.sql diff --git a/App/Requests/sql/zapros1.sql b/App/Requests/sql/sklad_material.sql similarity index 100% rename from App/Requests/sql/zapros1.sql rename to App/Requests/sql/sklad_material.sql From 2ba5b63b6534d7058d86c2a09f5968d8e7454f94 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 7 Nov 2024 16:30:47 +0300 Subject: [PATCH 08/33] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BD=D0=B0=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=B5=20select?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Auth/__init__.py | 4 ++-- App/Auth/sql/auth.sql | 2 +- App/Auth/templates/auth.html | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/App/Auth/__init__.py b/App/Auth/__init__.py index 4d4ad1e..6e92707 100644 --- a/App/Auth/__init__.py +++ b/App/Auth/__init__.py @@ -9,14 +9,14 @@ def auth(): return render_template('auth.html') else: data = request.form.to_dict() - data['table'] = 'internal_users' if 'internal' in data else 'external_users' + print(data) auth_data = auth_model(data) if auth_data.status: session.update({ 'login': auth_data.result[0]['login'], + 'access_user': data['access'], 'role': auth_data.result[0]['user_role'], 'db_config': current_app.config['db_config'], - 'access_user': 'in' if 'internal' in data else 'ext', 'permanent': True }) return redirect(url_for('index')) diff --git a/App/Auth/sql/auth.sql b/App/Auth/sql/auth.sql index 0902578..4fb90bf 100644 --- a/App/Auth/sql/auth.sql +++ b/App/Auth/sql/auth.sql @@ -1,4 +1,4 @@ -SELECT login, user_role FROM $table +SELECT login, user_role FROM $access WHERE login = '$login' AND password = '$password' LIMIT 1; \ No newline at end of file diff --git a/App/Auth/templates/auth.html b/App/Auth/templates/auth.html index 5ce4b62..3bed3b2 100644 --- a/App/Auth/templates/auth.html +++ b/App/Auth/templates/auth.html @@ -13,10 +13,15 @@
-

Внутренний пользователь

+

+ Уровень доступа: + +

- From 5211ab58a263f00619bb9a135c7bcab49993ab87 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 7 Nov 2024 16:31:04 +0300 Subject: [PATCH 09/33] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D1=80=D0=B5=D1=82=D0=BD=D0=BE=D0=B9=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D1=8B=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20?= =?UTF-8?q?=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/app.py | 2 +- App/templates/main_menu.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/App/app.py b/App/app.py index 4b49c69..887facd 100644 --- a/App/app.py +++ b/App/app.py @@ -26,4 +26,4 @@ def index(): def logout(): session.clear() return render_template('main_menu.html', ses=session) -app.run(port=5001, host='0.0.0.0') \ No newline at end of file +app.run(port=5002, host='0.0.0.0') \ No newline at end of file diff --git a/App/templates/main_menu.html b/App/templates/main_menu.html index 4afda31..479e5e0 100644 --- a/App/templates/main_menu.html +++ b/App/templates/main_menu.html @@ -12,7 +12,7 @@

Здравствуйте, {{ ses['login'] }}!

Ваша роль: {{ ses['role'] }}

- {% if ses['access_user'] == 'in' %} + {% if ses['access_user'] == 'internal_users' %}