From 32f3397f26454c541a9b1f08b15337bdce94aa80 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 22 Nov 2024 00:40:16 +0300 Subject: [PATCH 01/15] =?UTF-8?q?=D0=9F=D0=BE=D0=B4=D0=B3=D0=BE=D0=BD?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BE=D0=B4=20=D0=A0=D0=9F=D0=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/__init__.py | 12 ++++++------ App/Report/templates/report_basic.html | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/App/Report/__init__.py b/App/Report/__init__.py index 74ffaad..73ce20b 100644 --- a/App/Report/__init__.py +++ b/App/Report/__init__.py @@ -20,9 +20,9 @@ def menu(): def create(): if request.method == 'GET': return render_template('report_basic.html', - write=True, - title='Создание отчета', - items = report_list) + is_write=True, + title='Создание отчетов', + items=report_list) else: data = dict(id=request.form.get('category'), month=request.form.get('month'), @@ -46,9 +46,9 @@ def create(): def view(): if request.method == 'GET': return render_template('report_basic.html', - write=False, - title='Просмотр отчета', - items = report_list) + is_write=False, + title='Просмотр отчетов', + items=report_list) else: data = dict(id=request.form.get('category'), month=request.form.get('month'), diff --git a/App/Report/templates/report_basic.html b/App/Report/templates/report_basic.html index dbc693c..ab2de71 100644 --- a/App/Report/templates/report_basic.html +++ b/App/Report/templates/report_basic.html @@ -36,10 +36,10 @@ - + - {% if write %} + {% if is_write %} {% else %} From 763a001558b515fea4ee577d663daeb653809631 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Tue, 5 Nov 2024 22:58:34 +0300 Subject: [PATCH 02/15] =?UTF-8?q?=D0=9E=D1=81=D0=BD=D0=BE=D0=B2=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9=20=D0=BC=D0=BE=D0=B4=D0=B5=D0=BB=D0=B5=D1=80=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=B0=D0=BA=D0=BB=D0=B0=D0=B4=D0=BD?= =?UTF-8?q?=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/waybill_model.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 App/Waybill/waybill_model.py diff --git a/App/Waybill/waybill_model.py b/App/Waybill/waybill_model.py new file mode 100644 index 0000000..2928f24 --- /dev/null +++ b/App/Waybill/waybill_model.py @@ -0,0 +1,23 @@ +from Database.sql_provider import SQLProvider +from Database.select import select_list +from flask import current_app +from dataclasses import dataclass +import os + +@dataclass +class InfoRespronse: + result: tuple + error_message: str + status: bool + +sql_provider = SQLProvider(os.path.join(os.path.dirname(__file__), 'sql')) + + +def waybill_model(input_data) -> InfoRespronse: + _sql = sql_provider.get('waybill.sql', input_data) + result = select_list(current_app.config['db_config'], _sql) + if result is None: + return InfoRespronse((), + error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', + status=False) + return InfoRespronse(result, error_message='', status=True) \ No newline at end of file From bf8020afc8d535189b953555c06a2a8bdfb76573 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Sun, 17 Nov 2024 17:53:15 +0300 Subject: [PATCH 03/15] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE?= =?UTF-8?q?=D0=B2=D0=BA=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D0=BA?= =?UTF-8?q?=D0=BB=D0=B0=D0=B4=D0=BD=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/templates/waybill.html | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/App/Waybill/templates/waybill.html b/App/Waybill/templates/waybill.html index f81ea5c..bef2fb3 100644 --- a/App/Waybill/templates/waybill.html +++ b/App/Waybill/templates/waybill.html @@ -7,4 +7,19 @@ -

Заглушка для примера составления накладной

\ No newline at end of file +

Новая накладная

+
+ {% for item in items %} +
+

{{ item['name'] }}

+

В наличии {{ item['count'] }}

+ +
+ {% endfor %} + +
+ + + \ No newline at end of file From a86de70f05ef19c95d1166f6fdb17630d1d75b87 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 21 Nov 2024 17:54:51 +0300 Subject: [PATCH 04/15] =?UTF-8?q?=D0=92=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D0=BE=D0=B5=20=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=B5?= =?UTF-8?q?=D0=BA=20=D0=B7=D0=B0=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/templates/waybill.html | 35 ++++++++++++++++--------- App/static/css/waybill.css | 42 ++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 13 deletions(-) create mode 100644 App/static/css/waybill.css diff --git a/App/Waybill/templates/waybill.html b/App/Waybill/templates/waybill.html index bef2fb3..4d17692 100644 --- a/App/Waybill/templates/waybill.html +++ b/App/Waybill/templates/waybill.html @@ -7,19 +7,28 @@ -

Новая накладная

-
- {% for item in items %} -
-

{{ item['name'] }}

-

В наличии {{ item['count'] }}

- -
- {% endfor %} - -
-
- +

Заглушка для примера составления накладной

+
+ +
+ Фото товара +

Название товара 1

+

Цена: 500 руб.

+

Количество: 10 шт.

+
+
+ Фото товара +

Название товара 2

+

Цена: 1200 руб.

+

Количество: 5 шт.

+
+
+ Фото товара +

Название товара 3

+

Цена: 800 руб.

+

Количество: 7 шт.

+
+ \ No newline at end of file diff --git a/App/static/css/waybill.css b/App/static/css/waybill.css new file mode 100644 index 0000000..3d04723 --- /dev/null +++ b/App/static/css/waybill.css @@ -0,0 +1,42 @@ +.container { + display: flex; + flex-wrap: wrap; + gap: 20px; + padding: 20px; + justify-content: center; +} +.card { + background: #fff; + border: 1px solid #ddd; + border-radius: 10px; + width: 250px; + padding: 15px; + box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); + transition: transform 0.2s; +} +.card:hover { + transform: scale(1.05); +} +.card img { + width: 100%; + height: 150px; + object-fit: cover; + border-radius: 5px; +} +.card h3 { + margin: 10px 0; + font-size: 18px; + color: #333; +} +.card p { + margin: 5px 0; + color: #555; +} +.price { + font-weight: bold; + color: #28a745; +} +.quantity { + font-weight: bold; + color: #007bff; +} \ No newline at end of file From ae70a6d3f001cc39cbdf73cd5d048025a6b01616 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 21 Nov 2024 17:29:05 +0300 Subject: [PATCH 05/15] =?UTF-8?q?=D0=A1=D0=BA=D0=BE=D1=80=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=BD=D0=BE?= =?UTF-8?q?=D0=B5=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20Requests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/description.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/App/Requests/description.txt b/App/Requests/description.txt index c21fa76..1b4d300 100644 --- a/App/Requests/description.txt +++ b/App/Requests/description.txt @@ -5,14 +5,14 @@ │   ├── select.py - файл для выполнения select-запросов к СУБД │   └── sql_provider.py - SQL-провайдер для формирования запроса к СУБД ├── __init__.py - файл для инициализации Requests как модуль -├── requests_model.py - - реализация модели варианта с запросами +├── requests_model.py - реализация модели варианта работы с запросами ├── sql │   ├── materials_names.sql - sql-запрос для получения списка материалоа заготовок │   ├── sellers_names.sql - sql-запрос для получения списка поставщиков │   ├── ship_seller.sql - sql-запрос для получения списка поставок поставщиком │   └── sklad_material.sql - sql-запрос для получения списка заготовок на складе ├── templates -│   ├── sellers_ship.html +│   ├── sellers_ship.html - шаблон для формы передачи параметров для запроса всех поставок выбранного поставщика │   ├── zagotovki.html - шаблон для формы передачи параметров для запроса количества заготовок на складе -│   └── zapros_menu.html - шаблон для формы передачи параметров для запроса всех поставок выбранного поставщика +│   └── zapros_menu.html - шаблон для выбора варианта отчёта └── zapros_menu.json - файл с названиями запросов и их ссылками \ No newline at end of file From aaefc3494cca6cdd4bb144962a4f97bee5da3600 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 21 Nov 2024 17:29:15 +0300 Subject: [PATCH 06/15] =?UTF-8?q?=D0=9E=D0=BF=D0=B8=D1=81=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F=20Report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/description.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 App/Report/description.txt diff --git a/App/Report/description.txt b/App/Report/description.txt new file mode 100644 index 0000000..3889def --- /dev/null +++ b/App/Report/description.txt @@ -0,0 +1,20 @@ +. +├── access - json-файлы доступа к вариантам для формирования отчета +│   ├── 1.json +│   └── 2.json +├── db +│   ├── DBconnect.py - коннектор к СУБД +│   ├── __init__.py - файл для инициализации db как модуль +│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД +│   └── work.py - файл для выполнения select и call запросов +├── __init__.py - файл для инициализации Report как модуль +├── report_model.py - реализация модели варианта работы с отчетами +├── reports.json - файл с названиями отчетов и их идентификаторы +├── sql +│   ├── check_report.sql - sql-запрос для проверки наличия отчета в БД +│   ├── sellers_report.sql - sql-запрос для просмотра отчета о поставках поставщиков +│   └── workpiece_report.sql - sql-запрос для просмотра отчета о поставках заготовок +└── templates + ├── OK.html - шаблон для вывода информации об успешном добавлении отчета в БД + ├── report_basic.html - шаблон для ввода параметров просмотра/создания отчета + └── report_menu.html - шаблон для выбора просмотра/создания отчета \ No newline at end of file From 3872d9035c8d6988078b3176deb463d0c4b52b60 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 21 Nov 2024 18:40:38 +0300 Subject: [PATCH 07/15] =?UTF-8?q?=D0=9E=D1=81=D0=BD=D0=BE=D0=B2=D1=8B=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D0=BA=D0=BB=D0=B0=D0=B4=D0=BD?= =?UTF-8?q?=D1=8B=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/__init__.py | 4 ++- App/Waybill/templates/waybill.html | 56 +++++++++++++++++++----------- App/data/db_access.json | 2 +- App/static/css/waybill.css | 24 ++++++++----- App/templates/main_menu.html | 5 ++- 5 files changed, 58 insertions(+), 33 deletions(-) diff --git a/App/Waybill/__init__.py b/App/Waybill/__init__.py index c91ca76..66fdc1b 100644 --- a/App/Waybill/__init__.py +++ b/App/Waybill/__init__.py @@ -6,4 +6,6 @@ waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates') @check_auth def waybill(): if request.method == 'GET': - return render_template('waybill.html') \ No newline at end of file + return render_template('waybill.html') + print(request.form) + return 'OK' \ No newline at end of file diff --git a/App/Waybill/templates/waybill.html b/App/Waybill/templates/waybill.html index 4d17692..529270f 100644 --- a/App/Waybill/templates/waybill.html +++ b/App/Waybill/templates/waybill.html @@ -3,32 +3,46 @@ Авторизация - +

Заглушка для примера составления накладной

-
- -
- Фото товара -

Название товара 1

-

Цена: 500 руб.

-

Количество: 10 шт.

+
+
+ +
+ Фото товара +

Название товара 1

+

Цена: 500 руб.

+

Количество: 10 шт.

+
+ +
+
+
+ Фото товара +

Название товара 2

+

Цена: 1200 руб.

+

Количество: 5 шт.

+
+ +
+
+
+ Фото товара +

Название товара 3

+

Цена: 800 руб.

+

Количество: 7 шт.

+
+ +
+
-
- Фото товара -

Название товара 2

-

Цена: 1200 руб.

-

Количество: 5 шт.

+
+ +
-
- Фото товара -

Название товара 3

-

Цена: 800 руб.

-

Количество: 7 шт.

-
-
- +
\ No newline at end of file diff --git a/App/data/db_access.json b/App/data/db_access.json index a6ba414..16a79c5 100644 --- a/App/data/db_access.json +++ b/App/data/db_access.json @@ -7,6 +7,6 @@ "report_bp"], "Бухгалтер": [ "report_bp"], - "Поставщик": [ + "": [ "waybill_bp"] } \ No newline at end of file diff --git a/App/static/css/waybill.css b/App/static/css/waybill.css index 3d04723..048abb5 100644 --- a/App/static/css/waybill.css +++ b/App/static/css/waybill.css @@ -12,10 +12,6 @@ width: 250px; padding: 15px; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); - transition: transform 0.2s; -} -.card:hover { - transform: scale(1.05); } .card img { width: 100%; @@ -26,17 +22,27 @@ .card h3 { margin: 10px 0; font-size: 18px; - color: #333; -} -.card p { - margin: 5px 0; - color: #555; } .price { font-weight: bold; color: #28a745; } .quantity { + margin: 10px 0; font-weight: bold; color: #007bff; +} +.input-container { + margin: 10px 0; +} +.input-container input { + width: 80%; + padding: 8px; + font-size: 14px; + border: 1px solid #ddd; + border-radius: 5px; +} +.button-container { + text-align: center; + margin: 20px 0; } \ No newline at end of file diff --git a/App/templates/main_menu.html b/App/templates/main_menu.html index 288fbd0..fed3c58 100644 --- a/App/templates/main_menu.html +++ b/App/templates/main_menu.html @@ -19,7 +19,10 @@ {% else %} -

Not implemented

+ + {% endif %} {% else %} + diff --git a/App/static/js/check.js b/App/static/js/check.js new file mode 100644 index 0000000..e4546b0 --- /dev/null +++ b/App/static/js/check.js @@ -0,0 +1,7 @@ +function check_month(now_month) { + let selected_month = document.getElementById('month').value; + if (selected_month > now_month) { + alert('Невозможно сформировать отчет за будущий период!'); + return false; + } +} \ No newline at end of file From 54043aee1292b1fdd3fa86f662dc559d5ce572cc Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 22 Nov 2024 20:04:04 +0300 Subject: [PATCH 09/15] =?UTF-8?q?Css-=D0=BF=D1=80=D0=B5=D0=BE=D0=B1=D1=80?= =?UTF-8?q?=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Requests/templates/zapros_menu.html | 4 ++-- App/templates/main_menu.html | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/App/Requests/templates/zapros_menu.html b/App/Requests/templates/zapros_menu.html index e7d38b8..2030feb 100644 --- a/App/Requests/templates/zapros_menu.html +++ b/App/Requests/templates/zapros_menu.html @@ -10,11 +10,11 @@

Выберите вариант запроса

- +
diff --git a/App/templates/main_menu.html b/App/templates/main_menu.html index fed3c58..74b872b 100644 --- a/App/templates/main_menu.html +++ b/App/templates/main_menu.html @@ -14,15 +14,15 @@ {% if ses['access_user'] == 'internal_users' %}

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

- +
{% else %} - + {% endif %} {% else %}

{{ title }}

- + - +
{% if is_write %} diff --git a/App/static/js/check.js b/App/static/js/check.js index e4546b0..230c5ac 100644 --- a/App/static/js/check.js +++ b/App/static/js/check.js @@ -1,6 +1,7 @@ -function check_month(now_month) { +function check_month(now_month, now_year) { let selected_month = document.getElementById('month').value; - if (selected_month > now_month) { + let selected_year = document.getElementById('year').value; + if (selected_month > now_month && selected_year == now_year) { alert('Невозможно сформировать отчет за будущий период!'); return false; } From 82692375832ee4f390f6fbb5c49edf14785f0f13 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 22 Nov 2024 21:51:33 +0300 Subject: [PATCH 12/15] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BD=D0=B0=D0=BB=D0=B8=D1=87=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BE=D1=82=D1=87=D1=91=D1=82=D0=B0=20=D0=BA=D0=B0=D0=BA=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=86=D0=B5=D0=B4=D1=83=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/report_model.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/App/Report/report_model.py b/App/Report/report_model.py index 18ce3a2..468a77e 100644 --- a/App/Report/report_model.py +++ b/App/Report/report_model.py @@ -12,9 +12,8 @@ class InfoRespronse: status: bool def check_report(input_data: dict) -> bool: - _sql = sql_provider.get('check_report.sql', input_data) - result = select_list(current_app.config['db_config'], _sql) - if result is None or result[0]['exist'] == 0: + result = procedure(current_app.config['db_config'], 'check_report', tuple(input_data.values())) + if result is None or result['exist'] == 0: return False return True From 717f19414f2bca65a4a46c3a110678b99aed4cf9 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 22 Nov 2024 21:56:46 +0300 Subject: [PATCH 13/15] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20sql-=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= =?UTF-8?q?=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=BD?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D1=87=D0=B8=D1=8F=20=D0=BE=D1=82=D1=87=D1=91?= =?UTF-8?q?=D1=82=D0=B0=20+=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/description.txt | 3 +-- App/Report/sql/check_report.sql | 4 ---- 2 files changed, 1 insertion(+), 6 deletions(-) delete mode 100644 App/Report/sql/check_report.sql diff --git a/App/Report/description.txt b/App/Report/description.txt index 3889def..0572a31 100644 --- a/App/Report/description.txt +++ b/App/Report/description.txt @@ -10,8 +10,7 @@ ├── __init__.py - файл для инициализации Report как модуль ├── report_model.py - реализация модели варианта работы с отчетами ├── reports.json - файл с названиями отчетов и их идентификаторы -├── sql -│   ├── check_report.sql - sql-запрос для проверки наличия отчета в БД +├── sql  │   ├── sellers_report.sql - sql-запрос для просмотра отчета о поставках поставщиков │   └── workpiece_report.sql - sql-запрос для просмотра отчета о поставках заготовок └── templates diff --git a/App/Report/sql/check_report.sql b/App/Report/sql/check_report.sql deleted file mode 100644 index 7e6106a..0000000 --- a/App/Report/sql/check_report.sql +++ /dev/null @@ -1,4 +0,0 @@ -SELECT EXISTS ( - SELECT 1 FROM reports - WHERE report_category_id = '$id' AND (month = '$month' AND year = '$year') -) AS exist; \ No newline at end of file From b2020cf4728cfaa9d70c5b69160600d786b7612d Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 22 Nov 2024 22:54:19 +0300 Subject: [PATCH 14/15] =?UTF-8?q?=D0=95=D1=89=D1=91=20=D0=BE=D0=B4=D0=BD?= =?UTF-8?q?=D0=BE=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/description.txt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/App/Report/description.txt b/App/Report/description.txt index 0572a31..6908431 100644 --- a/App/Report/description.txt +++ b/App/Report/description.txt @@ -1,19 +1,16 @@ . -├── access - json-файлы доступа к вариантам для формирования отчета -│   ├── 1.json -│   └── 2.json ├── db │   ├── DBconnect.py - коннектор к СУБД │   ├── __init__.py - файл для инициализации db как модуль │   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД │   └── work.py - файл для выполнения select и call запросов ├── __init__.py - файл для инициализации Report как модуль -├── report_model.py - реализация модели варианта работы с отчетами -├── reports.json - файл с названиями отчетов и их идентификаторы +├── report_model.py - реализация модели варианта работы с отчётами +├── reports.json - файл с информацией о вариантах отчётов ├── sql  -│   ├── sellers_report.sql - sql-запрос для просмотра отчета о поставках поставщиков -│   └── workpiece_report.sql - sql-запрос для просмотра отчета о поставках заготовок +│   ├── sellers_report.sql - sql-запрос для просмотра отчёта о поставках поставщиков +│   └── workpiece_report.sql - sql-запрос для просмотра отчёта о поставках заготовок └── templates ├── OK.html - шаблон для вывода информации об успешном добавлении отчета в БД - ├── report_basic.html - шаблон для ввода параметров просмотра/создания отчета - └── report_menu.html - шаблон для выбора просмотра/создания отчета \ No newline at end of file + ├── report_basic.html - шаблон для ввода параметров просмотра/создания отчёта + └── report_menu.html - шаблон для выбора просмотра/создания отчёта \ No newline at end of file From a6c5ef988341e15a67a48bdfe6bb8e402630c49b Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Sat, 23 Nov 2024 11:48:55 +0300 Subject: [PATCH 15/15] =?UTF-8?q?=D0=A0=D0=B5=D0=BA=D0=BE=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B4=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BE=D1=82=20=D0=98?= =?UTF-8?q?=D0=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/__init__.py | 56 ++++++++++++-------------- App/Report/report_model.py | 81 +++++++++++++++++++++++++------------- App/Report/reports.json | 34 +++++++++------- 3 files changed, 100 insertions(+), 71 deletions(-) diff --git a/App/Report/__init__.py b/App/Report/__init__.py index e85f726..920a71c 100644 --- a/App/Report/__init__.py +++ b/App/Report/__init__.py @@ -1,8 +1,8 @@ -from flask import request, Blueprint, render_template, session, url_for +from flask import request, Blueprint, render_template, url_for from checker import check_auth from os import path from datetime import date -from .report_model import view_report, make_report +from .report_model import view_report_model, create_report_model import json with open(path.join(path.dirname(__file__), 'reports.json')) as f: @@ -16,6 +16,20 @@ def menu(): if request.method == 'GET': return render_template('report_menu.html') +# Рекомендации от ИС +# @report_bp.route('/test', methods=['GET']) +# def get_test(): +# return render_template('report_basic.html', +# is_write=True, +# title='Создание отчетов', +# items=report_list, +# date_today=date.today()) + +# @report_bp.route('/test', methods=['POST']) +# def post_test(): +# report_response = model(request, report_list) +# return view(report_response) + @report_bp.route('/create', methods=['GET', 'POST']) @check_auth def create(): @@ -26,20 +40,11 @@ def create(): items=report_list, date_today=date.today()) else: - id = request.form.get('category') - month = request.form.get('month') - year = request.form.get('year') - data = dict(id=id, month=month, year=year) - - if session['role'] in report_list[id]['data']['write']: - proc_name = report_list[id]['data']['procedure'] - ready_report = make_report(data, proc_name) - if ready_report.status: - return render_template("OK.html") - else: - return render_template("error.html", error_message=ready_report.error_message) + result = create_report_model(request, report_list) + if result.status: + return render_template("OK.html") else: - return render_template("error.html", error_message='Недостаточно прав для создания данного отчета!') + return render_template("error.html", error_message=result.error_message) @report_bp.route('/view', methods=['GET', 'POST']) @check_auth @@ -51,19 +56,10 @@ def view(): items=report_list, date_today=date.today()) else: - id = request.form.get('category') - month = request.form.get('month') - year = request.form.get('year') - data = dict(id=id, month=month, year=year) - - if session['role'] in report_list[id]['data']['read']: - ready_report = view_report(data, report_list[id]['data']['view']) - if ready_report.status: - title= f'{report_list[id]['data']['title']} за {data["month"]}-{data["year"]}' - return render_template("output.html", items=ready_report.result, - header=title, - link = url_for('report_bp.menu')) - else: - return render_template("error.html", error_message=ready_report.error_message) + result = view_report_model(request, report_list) + if result.status: + return render_template("output.html", items=result.result, + header='Результаты отчёта', + link = url_for('report_bp.menu')) else: - return render_template("error.html", error_message='Недосточно прав для чтения данного отчета!') \ No newline at end of file + return render_template("error.html", error_message=result.error_message) \ No newline at end of file diff --git a/App/Report/report_model.py b/App/Report/report_model.py index 468a77e..8127f5e 100644 --- a/App/Report/report_model.py +++ b/App/Report/report_model.py @@ -1,7 +1,7 @@ from dataclasses import dataclass from .db.work import select_list, procedure from .db.sql_provider import SQLProvider -from flask import current_app +from flask import current_app, session from os import path sql_provider = SQLProvider(path.join(path.dirname(__file__), 'sql')) @@ -17,32 +17,59 @@ def check_report(input_data: dict) -> bool: return False return True -def view_report(input_data: dict, view_script: str) -> InfoRespronse: - status = check_report(input_data) - if not status: - return InfoRespronse((), - error_message = 'Отчет не найден', - status=False) - - _sql = sql_provider.get(f'{view_script}.sql', input_data) - result = select_list(current_app.config['db_config'], _sql) - if result is None: - return InfoRespronse((), - error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', - status=False) - return InfoRespronse(result, error_message='', status=True) -def make_report(input_data: dict, proc_name: str) -> InfoRespronse: - status = check_report(input_data) - if status: - return InfoRespronse((), - error_message = 'Отчет уже существует', +def view_report_model(request, report_list: dict) -> InfoRespronse: + id = request.form.get('category') + month = request.form.get('month') + year = request.form.get('year') + + data = dict(id=id, month=month, year=year) + + if session['role'] in report_list[id]['data']['read']: + status = check_report(data) + if not status: + return InfoRespronse((), + error_message = 'Отчет не найден', + status=False) + + view_script = report_list[id]['data']['view'] + _sql = sql_provider.get(f'{view_script}.sql', data) + result = select_list(current_app.config['db_config'], _sql) + if result is None: + return InfoRespronse((), + error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', + status=False) + return InfoRespronse(result, error_message='', status=True) + else: + return InfoRespronse((), + error_message='Недостаточно прав для чтения данного отчета!', status=False) - data = tuple(input_data.values()) - result = procedure(current_app.config['db_config'], proc_name, data) - if result is None: - return InfoRespronse((), - error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', - status=False) - return InfoRespronse((), error_message='', status=True) \ No newline at end of file +def create_report_model(request, report_list: dict) -> InfoRespronse: + id = request.form.get('category') + month = request.form.get('month') + year = request.form.get('year') + + data = dict(id=id, month=month, year=year) + + if session['role'] in report_list[id]['data']['write']: + + status = check_report(data) + if status: + return InfoRespronse((), + error_message = 'Отчет уже существует', + status=False) + + proc_name = report_list[id]['data']['procedure'] + args = tuple(data.values()) + result = procedure(current_app.config['db_config'], proc_name, args) + + if result is None: + return InfoRespronse((), + error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', + status=False) + return InfoRespronse((), error_message='', status=True) + else: + return InfoRespronse((), + error_message='Недостаточно прав для создания данного отчета!', + status=False) \ No newline at end of file diff --git a/App/Report/reports.json b/App/Report/reports.json index fff8dfd..f6ab405 100644 --- a/App/Report/reports.json +++ b/App/Report/reports.json @@ -1,16 +1,22 @@ { - "1": {"name" : "Заготовки", "data": { - "title" : "Отчет о поставках заготовок", - "write" : ["Менеджер"], - "read" : ["Менеджер", "Управляющий"], - "view" : "workpiece_report", - "procedure" : "report_workpiece_2" - }}, - "2": {"name": "Поставщики", "data": { - "title" : "Отчет о поставках поставщиками", - "write" : ["Бухгалтер"], - "read" : ["Бухгалтер", "Управляющий"], - "view" : "sellers_report", - "procedure" : "report_sellers_2" - }} + "1": { + "name" : "Заготовки", + "data": { + "title" : "Отчет о поставках заготовок", + "write" : ["Менеджер"], + "read" : ["Менеджер", "Управляющий"], + "view" : "workpiece_report", + "procedure" : "report_workpiece_2" + } + }, + "2": { + "name": "Поставщики", + "data": { + "title" : "Отчет о поставках поставщиками", + "write" : ["Бухгалтер"], + "read" : ["Бухгалтер", "Управляющий"], + "view" : "sellers_report", + "procedure" : "report_sellers_2" + } + } } \ No newline at end of file