From 28f534fdf8d8a005bd694366818d4192d25c08e0 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 13:03:50 +0300 Subject: [PATCH 01/15] =?UTF-8?q?=D0=9A=D0=BE=D1=80=D1=80=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=B2=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B8=20=D0=BE=D1=84=D0=BE=D1=80=D0=BC=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=BD=D0=B0=D0=BA=D0=BB=D0=B0=D0=B4?= =?UTF-8?q?=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/App/Waybill/__init__.py b/App/Waybill/__init__.py index 55276bc..e2a0e72 100644 --- a/App/Waybill/__init__.py +++ b/App/Waybill/__init__.py @@ -1,7 +1,7 @@ from flask import request, Blueprint, render_template, session, redirect, url_for from checker import check_auth from .model import index_waybill, form_waybill, clear, button_click, transaction_order_model -from datetime import date +from datetime import datetime waybill_bp = Blueprint('waybill_bp', __name__, template_folder='templates', static_folder='static') @@ -37,7 +37,7 @@ def save_order(): return redirect(url_for('waybill_bp.index')) user_id = session.get('user_id',"") - current_date = date.today().strftime("%Y-%m-%d") + ' ' + date.today().strftime("%H:%M:%S") + current_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") result = transaction_order_model(user_id, current_date) if result.status: From 580b7d07e528c6ee4e91fa6a09fe96dae33d50ad Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 16:38:30 +0300 Subject: [PATCH 02/15] =?UTF-8?q?=D0=92=D1=8B=D0=B4=D0=B5=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=91=D0=94=20=D0=B8=20=D0=BA=D1=8D=D1=88?= =?UTF-8?q?=D0=B0=20=D0=BA=D0=B0=D0=BA=20=D0=BE=D1=82=D0=B4=D0=B5=D0=BB?= =?UTF-8?q?=D1=8C=D0=BD=D1=8B=D0=B5=20=D0=BC=D0=BE=D0=B4=D1=83=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/{Report/db => Database}/DBconnect.py | 3 +- App/{Report/db => Database}/__init__.py | 0 App/{Report/db => Database}/sql_provider.py | 0 App/{Report/db => Database}/work.py | 8 +++-- App/Requests/db/DBconnect.py | 34 --------------------- App/Requests/db/__init__.py | 0 App/Requests/db/select.py | 12 -------- App/Requests/db/sql_provider.py | 14 --------- App/Waybill/db/DBconnect.py | 34 --------------------- App/Waybill/db/__init__.py | 0 App/Waybill/db/sql_provider.py | 14 --------- App/Waybill/db/work.py | 16 ---------- App/{Waybill => }/cache/__init__.py | 0 App/{Waybill => }/cache/wrapper.py | 2 +- App/data/config.json | 3 +- 15 files changed, 11 insertions(+), 129 deletions(-) rename App/{Report/db => Database}/DBconnect.py (91%) rename App/{Report/db => Database}/__init__.py (100%) rename App/{Report/db => Database}/sql_provider.py (100%) rename App/{Report/db => Database}/work.py (83%) delete mode 100644 App/Requests/db/DBconnect.py delete mode 100644 App/Requests/db/__init__.py delete mode 100644 App/Requests/db/select.py delete mode 100644 App/Requests/db/sql_provider.py delete mode 100644 App/Waybill/db/DBconnect.py delete mode 100644 App/Waybill/db/__init__.py delete mode 100644 App/Waybill/db/sql_provider.py delete mode 100644 App/Waybill/db/work.py rename App/{Waybill => }/cache/__init__.py (100%) rename App/{Waybill => }/cache/wrapper.py (96%) diff --git a/App/Report/db/DBconnect.py b/App/Database/DBconnect.py similarity index 91% rename from App/Report/db/DBconnect.py rename to App/Database/DBconnect.py index b335654..2280c13 100644 --- a/App/Report/db/DBconnect.py +++ b/App/Database/DBconnect.py @@ -13,7 +13,8 @@ class DBContextManager: port=self.db_config['port'], user=self.db_config['user'], password=self.db_config['password'], - db=self.db_config['db'] + db=self.db_config['db'], + charset=self.db_config['charset'] ) self.cursor = self.connection.cursor() return self.cursor diff --git a/App/Report/db/__init__.py b/App/Database/__init__.py similarity index 100% rename from App/Report/db/__init__.py rename to App/Database/__init__.py diff --git a/App/Report/db/sql_provider.py b/App/Database/sql_provider.py similarity index 100% rename from App/Report/db/sql_provider.py rename to App/Database/sql_provider.py diff --git a/App/Report/db/work.py b/App/Database/work.py similarity index 83% rename from App/Report/db/work.py rename to App/Database/work.py index 2fd1ff3..6437858 100644 --- a/App/Report/db/work.py +++ b/App/Database/work.py @@ -11,7 +11,7 @@ def select_list(db_config, sql) -> list: lst = [dict(zip(schema, row)) for row in result] return lst -def procedure(db_config, name, args: tuple): +def procedure(db_config, name, args: tuple) -> list: with DBContextManager(db_config) as cursor: if cursor is None: raise ValueError("Cursor not created") @@ -20,4 +20,8 @@ def procedure(db_config, name, args: tuple): result = cursor.fetchall()[0] schema = cursor.description[0] lst = dict(zip(schema, result)) - return lst \ No newline at end of file + return lst + +def transaction(cursor, sql): + cursor.execute(sql) + return True \ No newline at end of file diff --git a/App/Requests/db/DBconnect.py b/App/Requests/db/DBconnect.py deleted file mode 100644 index b335654..0000000 --- a/App/Requests/db/DBconnect.py +++ /dev/null @@ -1,34 +0,0 @@ -import pymysql -from pymysql.err import * -class DBContextManager: - def __init__(self, db_config : dict): - self.db_config = db_config - self.connection = None - self.cursor = None - - def __enter__(self): - try: - self.connection = pymysql.connect( - host=self.db_config['host'], - port=self.db_config['port'], - user=self.db_config['user'], - password=self.db_config['password'], - db=self.db_config['db'] - ) - self.cursor = self.connection.cursor() - return self.cursor - except (OperationalError, KeyError) as err: - print(err.args) - return None - - def __exit__(self, exc_type, exc_val, exc_tb): - if self.connection and self.cursor: - if exc_type: - print(exc_type, '\n', exc_val) - self.connection.rollback() - else: - self.connection.commit() - self.cursor.close() - self.connection.close() - return True - \ No newline at end of file diff --git a/App/Requests/db/__init__.py b/App/Requests/db/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/App/Requests/db/select.py b/App/Requests/db/select.py deleted file mode 100644 index 22cc3e7..0000000 --- a/App/Requests/db/select.py +++ /dev/null @@ -1,12 +0,0 @@ -from .DBconnect import DBContextManager - -def select_list(db_config, sql) -> list: - with DBContextManager(db_config) as cursor: - if cursor is None: - raise ValueError("Cursor not created") - else: - cursor.execute(sql) - result = cursor.fetchall() - schema = [item[0] for item in cursor.description] - lst = [dict(zip(schema, row)) for row in result] - return lst \ No newline at end of file diff --git a/App/Requests/db/sql_provider.py b/App/Requests/db/sql_provider.py deleted file mode 100644 index a3a1855..0000000 --- a/App/Requests/db/sql_provider.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -from string import Template - -class SQLProvider: - def __init__(self, file_path): - self.scripts = {} - for file in os.listdir(file_path): - _sql = open(f'{file_path}/{file}').read() - self.scripts[file] = Template(_sql) - - def get(self, name, params) -> dict: - if name not in self.scripts: - raise ValueError(f'SQL template {name} not found') - return self.scripts[name].substitute(**params) \ No newline at end of file diff --git a/App/Waybill/db/DBconnect.py b/App/Waybill/db/DBconnect.py deleted file mode 100644 index b335654..0000000 --- a/App/Waybill/db/DBconnect.py +++ /dev/null @@ -1,34 +0,0 @@ -import pymysql -from pymysql.err import * -class DBContextManager: - def __init__(self, db_config : dict): - self.db_config = db_config - self.connection = None - self.cursor = None - - def __enter__(self): - try: - self.connection = pymysql.connect( - host=self.db_config['host'], - port=self.db_config['port'], - user=self.db_config['user'], - password=self.db_config['password'], - db=self.db_config['db'] - ) - self.cursor = self.connection.cursor() - return self.cursor - except (OperationalError, KeyError) as err: - print(err.args) - return None - - def __exit__(self, exc_type, exc_val, exc_tb): - if self.connection and self.cursor: - if exc_type: - print(exc_type, '\n', exc_val) - self.connection.rollback() - else: - self.connection.commit() - self.cursor.close() - self.connection.close() - return True - \ No newline at end of file diff --git a/App/Waybill/db/__init__.py b/App/Waybill/db/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/App/Waybill/db/sql_provider.py b/App/Waybill/db/sql_provider.py deleted file mode 100644 index a3a1855..0000000 --- a/App/Waybill/db/sql_provider.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -from string import Template - -class SQLProvider: - def __init__(self, file_path): - self.scripts = {} - for file in os.listdir(file_path): - _sql = open(f'{file_path}/{file}').read() - self.scripts[file] = Template(_sql) - - def get(self, name, params) -> dict: - if name not in self.scripts: - raise ValueError(f'SQL template {name} not found') - return self.scripts[name].substitute(**params) \ No newline at end of file diff --git a/App/Waybill/db/work.py b/App/Waybill/db/work.py deleted file mode 100644 index 5a7f039..0000000 --- a/App/Waybill/db/work.py +++ /dev/null @@ -1,16 +0,0 @@ -from .DBconnect import DBContextManager - -def select_list(db_config, sql) -> list: - with DBContextManager(db_config) as cursor: - if cursor is None: - raise ValueError("Cursor not created") - else: - cursor.execute(sql) - result = cursor.fetchall() - schema = [item[0] for item in cursor.description] - lst = [dict(zip(schema, row)) for row in result] - return lst - -def transaction(cursor, sql): - cursor.execute(sql) - return True \ No newline at end of file diff --git a/App/Waybill/cache/__init__.py b/App/cache/__init__.py similarity index 100% rename from App/Waybill/cache/__init__.py rename to App/cache/__init__.py diff --git a/App/Waybill/cache/wrapper.py b/App/cache/wrapper.py similarity index 96% rename from App/Waybill/cache/wrapper.py rename to App/cache/wrapper.py index ff38803..64b2343 100644 --- a/App/Waybill/cache/wrapper.py +++ b/App/cache/wrapper.py @@ -1,5 +1,5 @@ from functools import wraps -from Waybill.cache import RedisCache +from . import RedisCache def fetch_from_cache(cache_name: str, cache_config: dict): cache_conn = RedisCache(cache_config['redis']) diff --git a/App/data/config.json b/App/data/config.json index 8b7b193..0f0565b 100644 --- a/App/data/config.json +++ b/App/data/config.json @@ -3,5 +3,6 @@ "port": 3306, "user": "manager", "password": "ilikepizza", - "db": "sklad" + "db": "sklad", + "charset": "utf8" } \ No newline at end of file From 91b82ecea9676ddd1455f54e3b5eb4e37581a04e Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 16:39:05 +0300 Subject: [PATCH 03/15] =?UTF-8?q?=D0=90=D0=B4=D0=B0=D0=BF=D1=82=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D1=8F=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=81=D0=B8=D1=81=D1=82=D0=B5?= =?UTF-8?q?=D0=BC=D1=8B=20=D0=BF=D0=BE=D0=B4=20=D0=BC=D0=BE=D0=B4=D1=83?= =?UTF-8?q?=D0=BB=D0=B8=20Database=20=D0=B8=20cache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/__init__.py | 2 +- App/Report/report_model.py | 4 ++-- App/Requests/requests_model.py | 4 ++-- App/Waybill/model.py | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/App/Report/__init__.py b/App/Report/__init__.py index 920a71c..5794625 100644 --- a/App/Report/__init__.py +++ b/App/Report/__init__.py @@ -5,7 +5,7 @@ from datetime import date from .report_model import view_report_model, create_report_model import json -with open(path.join(path.dirname(__file__), 'reports.json')) as f: +with open(path.join(path.dirname(__file__), 'reports.json'), encoding='utf-8') as f: report_list = json.load(f) report_bp = Blueprint('report_bp', __name__, template_folder='templates') diff --git a/App/Report/report_model.py b/App/Report/report_model.py index 8127f5e..11e4568 100644 --- a/App/Report/report_model.py +++ b/App/Report/report_model.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from .db.work import select_list, procedure -from .db.sql_provider import SQLProvider +from Database.work import select_list, procedure +from Database.sql_provider import SQLProvider from flask import current_app, session from os import path diff --git a/App/Requests/requests_model.py b/App/Requests/requests_model.py index 3841ef7..75466bb 100644 --- a/App/Requests/requests_model.py +++ b/App/Requests/requests_model.py @@ -1,6 +1,6 @@ from dataclasses import dataclass -from .db.select import select_list -from .db.sql_provider import SQLProvider +from Database.work import select_list +from Database.sql_provider import SQLProvider from flask import current_app from os import path diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 01162b1..63cf7d0 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -1,11 +1,11 @@ -from .db.sql_provider import SQLProvider -from .db.work import select_list, transaction -from .db.DBconnect import DBContextManager +from Database.sql_provider import SQLProvider +from Database.work import select_list, transaction +from Database.DBconnect import DBContextManager from flask import current_app, session from dataclasses import dataclass from datetime import date -from .cache.wrapper import fetch_from_cache +from cache.wrapper import fetch_from_cache import os @dataclass From e28ccaab143edcb8232cec2b9ef70887d173b47a Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 18:05:08 +0300 Subject: [PATCH 04/15] =?UTF-8?q?=D0=94=D0=BB=D1=8F=20=D1=81=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=B0=D1=82=D1=8B=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D1=82?= =?UTF-8?q?=D1=80=D0=B8=D0=B3=D0=B3=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/model.py | 35 ++++++++++++--------------- App/Waybill/sql/good_price.sql | 1 + App/Waybill/sql/insert_order_line.sql | 3 +-- 3 files changed, 17 insertions(+), 22 deletions(-) create mode 100644 App/Waybill/sql/good_price.sql diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 63cf7d0..48d4488 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -72,13 +72,6 @@ def button_click(request): print(session['waybill']) session.modified = True - # elif request.form.get('product_display_plus'): - # # increasing count in waybill - - # amount = int(session['waybill'][str(product['work_id'])]) - # session['waybill'][str(product['work_id'])] = str(amount + 1) - # session.modified = True - elif request.form.get('product_display_minus'): # decreasing count in waybill @@ -101,23 +94,25 @@ def transaction_order_model(user_id: int, current_date: date): with DBContextManager(db_config) as cursor: data = dict(e_user_id=user_id, e_order_date=current_date, e_total=total) - - _sql = sql_provider.get('create_order.sql', data) try: + _sql = sql_provider.get('create_order.sql', data) cursor.execute(_sql) + + order_id = cursor.lastrowid + for key, value in waybill.items(): + _sql = sql_provider.get('good_price.sql', dict( + e_prod_id = int(key) + )) + price = select_list(db_config, _sql)[0][0] + + _sql = sql_provider.get('insert_order_line.sql', + dict(e_order_id = order_id, + e_price = price, + e_prod_id = int(key), + e_amount = int(value))) + cursor.execute(_sql) except: return InfoRespronse((), error_message="Заказ не был создан", status=False) - - order_id = cursor.lastrowid - for key, value in waybill.items(): - _sql = sql_provider.get('insert_order_line.sql', - dict(e_order_id = order_id, - e_prod_id = int(key), - e_amount = int(value))) - try: - cursor.execute(_sql) - except: - return InfoRespronse((), error_message="Заказ не был создан", status=False) result = tuple([order_id]) clear() diff --git a/App/Waybill/sql/good_price.sql b/App/Waybill/sql/good_price.sql new file mode 100644 index 0000000..d01f1ec --- /dev/null +++ b/App/Waybill/sql/good_price.sql @@ -0,0 +1 @@ +SELECT price FROM workpiece WHERE work_id = $e_prod_id \ No newline at end of file diff --git a/App/Waybill/sql/insert_order_line.sql b/App/Waybill/sql/insert_order_line.sql index 26091a8..4eaeb65 100644 --- a/App/Waybill/sql/insert_order_line.sql +++ b/App/Waybill/sql/insert_order_line.sql @@ -1,2 +1 @@ -INSERT INTO `waybill_lines` VALUES ($e_order_id, $e_prod_id, -(SELECT price FROM workpiece WHERE work_id = $e_prod_id), $e_amount); \ No newline at end of file +INSERT INTO `waybill_lines` VALUES ($e_order_id, $e_prod_id, $e_price, $e_amount); \ No newline at end of file From 7c74289522871be470b1b6a5d3c0254daba80891 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 18:09:39 +0300 Subject: [PATCH 05/15] =?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?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/model.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 48d4488..9a1c584 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -103,7 +103,9 @@ def transaction_order_model(user_id: int, current_date: date): _sql = sql_provider.get('good_price.sql', dict( e_prod_id = int(key) )) - price = select_list(db_config, _sql)[0][0] + cursor.execute(_sql) + result = cursor.fetchone() + price = result[0] _sql = sql_provider.get('insert_order_line.sql', dict(e_order_id = order_id, From 54aa201650512e7c6710694b78f38f7b3efbe584 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 22:22:53 +0300 Subject: [PATCH 06/15] =?UTF-8?q?=D0=90=D0=BA=D1=82=D1=83=D0=B0=D0=BB?= =?UTF-8?q?=D0=B8=D0=B7=D0=B0=D1=86=D0=B8=D1=8F=20=D1=86=D0=B5=D0=BD=D1=8B?= =?UTF-8?q?=20=D0=B2=20=D1=82=D1=80=D0=B8=D0=B3=D0=B3=D0=B5=D1=80=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/model.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 9a1c584..9d912d4 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -100,16 +100,9 @@ def transaction_order_model(user_id: int, current_date: date): order_id = cursor.lastrowid for key, value in waybill.items(): - _sql = sql_provider.get('good_price.sql', dict( - e_prod_id = int(key) - )) - cursor.execute(_sql) - result = cursor.fetchone() - price = result[0] - _sql = sql_provider.get('insert_order_line.sql', dict(e_order_id = order_id, - e_price = price, + e_price = 0, e_prod_id = int(key), e_amount = int(value))) cursor.execute(_sql) From f265553cfc9e5dd3738cc178d72bc8cbdae042ad Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Wed, 4 Dec 2024 23:10:17 +0300 Subject: [PATCH 07/15] =?UTF-8?q?=D0=9D=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=B4?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=D0=BB=D0=B8=20=D0=BE=20=D0=B7=D0=B0=D0=B3?= =?UTF-8?q?=D0=BE=D1=82=D0=BE=D0=B2=D0=BA=D0=B0=D1=85=20=D0=B2=20=D0=BA?= =?UTF-8?q?=D0=B0=D1=80=D1=82=D0=BE=D1=87=D0=BA=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/sql/goods.sql | 2 +- App/Waybill/templates/card.html | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/App/Waybill/sql/goods.sql b/App/Waybill/sql/goods.sql index 9a18e9b..ad8e437 100644 --- a/App/Waybill/sql/goods.sql +++ b/App/Waybill/sql/goods.sql @@ -1 +1 @@ -SELECT work_id, name, price, material, count FROM workpiece \ No newline at end of file +SELECT work_id, name, price, material, count, weight FROM workpiece \ No newline at end of file diff --git a/App/Waybill/templates/card.html b/App/Waybill/templates/card.html index b6248d6..b5dd9e5 100644 --- a/App/Waybill/templates/card.html +++ b/App/Waybill/templates/card.html @@ -4,6 +4,8 @@
{{ item['name'] }}

Цена: {{ item['price'] }} ₽

+

Материал: {{ item['material'] }}

+

Вес: {{ item['weight'] }} г

{% if show_amount %} Количество: {{item['amount']}}
From 8b3c0e0fcc3de25c3b1c39cc1758dca73185c322 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Thu, 5 Dec 2024 23:18:52 +0300 Subject: [PATCH 08/15] =?UTF-8?q?=D0=9A=D1=8D=D1=88=D0=B8=D1=80=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D1=82=D0=BE=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=B8=D0=B7=20=D0=BD=D0=B0=D0=BA=D0=BB=D0=B0?= =?UTF-8?q?=D0=B4=D0=BD=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Waybill/model.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 9d912d4..0f908ef 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -21,11 +21,15 @@ def clear(): session.pop('waybill') def form_waybill() -> list: + db_config = current_app.config['db_config'] + cache_config = current_app.config['cache_config'] + current_waybill = session.get('waybill',{}) waybill = [] for k,v in current_waybill.items(): _sql = sql_provider.get('one_good.sql', dict(work_id=k)) - product = select_list(current_app.config['db_config'], _sql)[0] + cache_select = fetch_from_cache(f'product_{k}', cache_config)(select_list) + product = cache_select(db_config, _sql)[0] product['amount'] = v waybill.append(product) return waybill From c1367bb47e14612c1bd3356fa527081cf85046ad Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 15:11:44 +0300 Subject: [PATCH 09/15] =?UTF-8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=BE=D0=BF?= =?UTF-8?q?=D1=80=D0=B5=D0=B4=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BC=D0=BE?= =?UTF-8?q?=D0=B4=D1=83=D0=BB=D1=8F=20=D0=A1=D0=A3=D0=91=D0=94=20=D0=B4?= =?UTF-8?q?=D0=BB=D1=8F=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8=D0=B7=D0=B0?= =?UTF-8?q?=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Auth/__init__.py | 2 +- App/Auth/auth_model.py | 10 +++++++--- App/Auth/db/DBconnect.py | 34 ---------------------------------- App/Auth/db/__init__.py | 0 App/Auth/db/select.py | 12 ------------ App/Auth/db/sql_provider.py | 14 -------------- 6 files changed, 8 insertions(+), 64 deletions(-) delete mode 100644 App/Auth/db/DBconnect.py delete mode 100644 App/Auth/db/__init__.py delete mode 100644 App/Auth/db/select.py delete mode 100644 App/Auth/db/sql_provider.py diff --git a/App/Auth/__init__.py b/App/Auth/__init__.py index 402607f..ed7e55a 100644 --- a/App/Auth/__init__.py +++ b/App/Auth/__init__.py @@ -1,4 +1,4 @@ -from flask import request, Blueprint, render_template, session, current_app, redirect, url_for +from flask import Blueprint, render_template, redirect, url_for, request, session from .auth_model import auth_model auth_bp = Blueprint('auth_bp', __name__, template_folder='templates') diff --git a/App/Auth/auth_model.py b/App/Auth/auth_model.py index 7446ac6..b3cab0b 100644 --- a/App/Auth/auth_model.py +++ b/App/Auth/auth_model.py @@ -1,6 +1,8 @@ from dataclasses import dataclass -from .db.select import select_list -from .db.sql_provider import SQLProvider + +from Database.work import select_list +from Database.sql_provider import SQLProvider + from flask import current_app import os @@ -12,8 +14,10 @@ class InfoRespronse: status: bool def auth_model(input_data) -> InfoRespronse: + db_config = current_app.config['db_config'] + _sql = sql_provider.get('auth.sql', input_data) - user = select_list(current_app.config['db_config'], _sql) + user = select_list(db_config, _sql) if user is None: return InfoRespronse((), error_message = 'Ошибка при подключении к БД', diff --git a/App/Auth/db/DBconnect.py b/App/Auth/db/DBconnect.py deleted file mode 100644 index b335654..0000000 --- a/App/Auth/db/DBconnect.py +++ /dev/null @@ -1,34 +0,0 @@ -import pymysql -from pymysql.err import * -class DBContextManager: - def __init__(self, db_config : dict): - self.db_config = db_config - self.connection = None - self.cursor = None - - def __enter__(self): - try: - self.connection = pymysql.connect( - host=self.db_config['host'], - port=self.db_config['port'], - user=self.db_config['user'], - password=self.db_config['password'], - db=self.db_config['db'] - ) - self.cursor = self.connection.cursor() - return self.cursor - except (OperationalError, KeyError) as err: - print(err.args) - return None - - def __exit__(self, exc_type, exc_val, exc_tb): - if self.connection and self.cursor: - if exc_type: - print(exc_type, '\n', exc_val) - self.connection.rollback() - else: - self.connection.commit() - self.cursor.close() - self.connection.close() - return True - \ No newline at end of file diff --git a/App/Auth/db/__init__.py b/App/Auth/db/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/App/Auth/db/select.py b/App/Auth/db/select.py deleted file mode 100644 index 22cc3e7..0000000 --- a/App/Auth/db/select.py +++ /dev/null @@ -1,12 +0,0 @@ -from .DBconnect import DBContextManager - -def select_list(db_config, sql) -> list: - with DBContextManager(db_config) as cursor: - if cursor is None: - raise ValueError("Cursor not created") - else: - cursor.execute(sql) - result = cursor.fetchall() - schema = [item[0] for item in cursor.description] - lst = [dict(zip(schema, row)) for row in result] - return lst \ No newline at end of file diff --git a/App/Auth/db/sql_provider.py b/App/Auth/db/sql_provider.py deleted file mode 100644 index a3a1855..0000000 --- a/App/Auth/db/sql_provider.py +++ /dev/null @@ -1,14 +0,0 @@ -import os -from string import Template - -class SQLProvider: - def __init__(self, file_path): - self.scripts = {} - for file in os.listdir(file_path): - _sql = open(f'{file_path}/{file}').read() - self.scripts[file] = Template(_sql) - - def get(self, name, params) -> dict: - if name not in self.scripts: - raise ValueError(f'SQL template {name} not found') - return self.scripts[name].substitute(**params) \ No newline at end of file From f8c79939b419c6acd29fb79770f530067511d143 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 15:12:21 +0300 Subject: [PATCH 10/15] =?UTF-8?q?=D0=A3=D0=BD=D0=B8=D1=84=D0=B8=D0=BA?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D1=8F=20=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=BA=D0=BE=D0=BD?= =?UTF-8?q?=D1=84=D0=B8=D0=B3=D1=83=D1=80=D0=B0=D1=86=D0=B8=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20?= =?UTF-8?q?=D0=BA=20=D0=A1=D0=A3=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/report_model.py | 12 +++++++++--- App/Requests/requests_model.py | 18 ++++++++++++++---- App/Waybill/__init__.py | 2 +- App/Waybill/model.py | 4 +++- 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/App/Report/report_model.py b/App/Report/report_model.py index 11e4568..9125413 100644 --- a/App/Report/report_model.py +++ b/App/Report/report_model.py @@ -1,6 +1,8 @@ from dataclasses import dataclass + from Database.work import select_list, procedure from Database.sql_provider import SQLProvider + from flask import current_app, session from os import path @@ -12,7 +14,9 @@ class InfoRespronse: status: bool def check_report(input_data: dict) -> bool: - result = procedure(current_app.config['db_config'], 'check_report', tuple(input_data.values())) + db_config = current_app.config['db_config'] + + result = procedure(db_config, 'check_report', tuple(input_data.values())) if result is None or result['exist'] == 0: return False return True @@ -32,9 +36,10 @@ def view_report_model(request, report_list: dict) -> InfoRespronse: error_message = 'Отчет не найден', status=False) + db_config = current_app.config['db_config'] 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) + result = select_list(db_config, _sql) if result is None: return InfoRespronse((), error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', @@ -60,9 +65,10 @@ def create_report_model(request, report_list: dict) -> InfoRespronse: error_message = 'Отчет уже существует', status=False) + db_config = current_app.config['db_config'] proc_name = report_list[id]['data']['procedure'] args = tuple(data.values()) - result = procedure(current_app.config['db_config'], proc_name, args) + result = procedure(db_config, proc_name, args) if result is None: return InfoRespronse((), diff --git a/App/Requests/requests_model.py b/App/Requests/requests_model.py index 75466bb..e23513b 100644 --- a/App/Requests/requests_model.py +++ b/App/Requests/requests_model.py @@ -1,6 +1,8 @@ from dataclasses import dataclass + from Database.work import select_list from Database.sql_provider import SQLProvider + from flask import current_app from os import path @@ -12,8 +14,10 @@ class InfoRespronse: status: bool def sellers_names() -> InfoRespronse: + db_config = current_app.config['db_config'] + _sql = sql_provider.get('sellers_names.sql', {}) - result = select_list(current_app.config['db_config'], _sql) + result = select_list(db_config, _sql) if result is None: return InfoRespronse((), error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', @@ -21,8 +25,10 @@ def sellers_names() -> InfoRespronse: return InfoRespronse(result, error_message='', status=True) def materials_names() -> InfoRespronse: + db_config = current_app.config['db_config'] + _sql = sql_provider.get('materials_names.sql', {}) - result = select_list(current_app.config['db_config'], _sql) + result = select_list(db_config, _sql) if result is None: return InfoRespronse((), error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', @@ -30,9 +36,11 @@ def materials_names() -> InfoRespronse: return InfoRespronse(result, error_message='', status=True) def sklad(request) -> InfoRespronse: + db_config = current_app.config['db_config'] material = dict(request.form) + _sql = sql_provider.get('sklad_material.sql', material) - result = select_list(current_app.config['db_config'], _sql) + result = select_list(db_config, _sql) if result is None: return InfoRespronse((), error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', @@ -41,9 +49,11 @@ def sklad(request) -> InfoRespronse: def materials_per_seller(request) -> InfoRespronse: + db_config = current_app.config['db_config'] + seller = dict(request.form) _sql = sql_provider.get('ship_seller.sql', seller) - result = select_list(current_app.config['db_config'], _sql) + result = select_list(db_config, _sql) if result is None: return InfoRespronse((), error_message = 'Ошибка в подключении к базе данных. Свяжитесь с администратором', diff --git a/App/Waybill/__init__.py b/App/Waybill/__init__.py index e2a0e72..2701981 100644 --- a/App/Waybill/__init__.py +++ b/App/Waybill/__init__.py @@ -1,4 +1,4 @@ -from flask import request, Blueprint, render_template, session, redirect, url_for +from flask import Blueprint, render_template, redirect, url_for, session, request from checker import check_auth from .model import index_waybill, form_waybill, clear, button_click, transaction_order_model from datetime import datetime diff --git a/App/Waybill/model.py b/App/Waybill/model.py index 0f908ef..075f385 100644 --- a/App/Waybill/model.py +++ b/App/Waybill/model.py @@ -1,5 +1,5 @@ from Database.sql_provider import SQLProvider -from Database.work import select_list, transaction +from Database.work import select_list from Database.DBconnect import DBContextManager from flask import current_app, session @@ -41,6 +41,8 @@ def index_waybill() -> list: cache_select = fetch_from_cache('items_cached', cache_config)(select_list) _sql = sql_provider.get('goods.sql', {}) products = cache_select(db_config, _sql) + if products == None: + return [] return products From ec1972b0bb8242e8d1cc12fc5a73a143073bddac Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 15:12:30 +0300 Subject: [PATCH 11/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=B4=D0=B5=D0=BA=D0=BE=D1=80=D0=B0=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/cache/wrapper.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/App/cache/wrapper.py b/App/cache/wrapper.py index 64b2343..11cd216 100644 --- a/App/cache/wrapper.py +++ b/App/cache/wrapper.py @@ -4,14 +4,13 @@ from . import RedisCache def fetch_from_cache(cache_name: str, cache_config: dict): cache_conn = RedisCache(cache_config['redis']) ttl = cache_config['ttl'] + + """ + It checks if a cached value exists for a given cache_name. + If a cached value exists, it returns the cached value. + If no cached value exists, it calls the original function f with the provided arguments, caches the result, and then returns the result. + """ def decorator(f): - # как оно работает - # лезем в кэш и смотрим, есть ли там что-то - # если есть, то возвращаем кэшированную информацию - # если нет, то запускаем декорируемую функцию - # достаём оттуда информацию - # заносим её в кэш - # возвращаем кэшированную информацию @wraps(f) def wrapper(*args, **kwargs): cached_value = cache_conn.get_value(cache_name) From 044564dd2073aa823a4ae5fccd80862b702efa57 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 15:14:33 +0300 Subject: [PATCH 12/15] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=D1=8D=D1=88-=D0=BF=D0=B0=D0=BF=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache_delete.sh | 1 + 1 file changed, 1 insertion(+) create mode 100644 cache_delete.sh diff --git a/cache_delete.sh b/cache_delete.sh new file mode 100644 index 0000000..3890bd7 --- /dev/null +++ b/cache_delete.sh @@ -0,0 +1 @@ +find . -type d -name "__pycache__" -exec rm -rf {} + \ No newline at end of file From 37a836a222224053a5778c72b2ef561980a43340 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 16:13:57 +0300 Subject: [PATCH 13/15] =?UTF-8?q?=D0=A1=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=D0=B5=D1=88=D0=B0=20python?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cache_delete.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cache_delete.sh diff --git a/cache_delete.sh b/cache_delete.sh old mode 100644 new mode 100755 From 54071f20beb484f3d15966f083834699a28757ff Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 16:14:21 +0300 Subject: [PATCH 14/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=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Auth/description.txt | 13 ------------- App/Report/description.txt | 16 ---------------- App/Requests/description.txt | 18 ------------------ App/auth.txt | 13 +++++++++++++ App/description.txt | 16 ---------------- App/main.txt | 19 +++++++++++++++++++ App/report.txt | 22 ++++++++++++++++++++++ App/requests.txt | 19 +++++++++++++++++++ App/waybill.txt | 25 +++++++++++++++++++++++++ 9 files changed, 98 insertions(+), 63 deletions(-) delete mode 100644 App/Auth/description.txt delete mode 100644 App/Report/description.txt delete mode 100644 App/Requests/description.txt create mode 100644 App/auth.txt delete mode 100644 App/description.txt create mode 100644 App/main.txt create mode 100644 App/report.txt create mode 100644 App/requests.txt create mode 100644 App/waybill.txt diff --git a/App/Auth/description.txt b/App/Auth/description.txt deleted file mode 100644 index b8d4d0b..0000000 --- a/App/Auth/description.txt +++ /dev/null @@ -1,13 +0,0 @@ -. -├── auth_model.py - реализация модели авторизации -├── db -│   ├── DBconnect.py - коннектор к СУБД -│   ├── __init__.py - файл для инициализации db как модуль -│   ├── select.py - файл для выполнения select-запросов к СУБД -│   └── sql_provider.py - SQL-провайдер для формирования запроса к СУБД -├── __init__.py - файл для инициализации Auth как модуль -├── sql -│   └── auth.sql - sql-запрос, проверяющий наличие пользователя в СУБД -└── templates - └── auth.html - шаблон для страницы авторизации - diff --git a/App/Report/description.txt b/App/Report/description.txt deleted file mode 100644 index 6908431..0000000 --- a/App/Report/description.txt +++ /dev/null @@ -1,16 +0,0 @@ -. -├── db -│   ├── DBconnect.py - коннектор к СУБД -│   ├── __init__.py - файл для инициализации db как модуль -│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД -│   └── work.py - файл для выполнения select и call запросов -├── __init__.py - файл для инициализации Report как модуль -├── report_model.py - реализация модели варианта работы с отчётами -├── reports.json - файл с информацией о вариантах отчётов -├── sql  -│   ├── sellers_report.sql - sql-запрос для просмотра отчёта о поставках поставщиков -│   └── workpiece_report.sql - sql-запрос для просмотра отчёта о поставках заготовок -└── templates - ├── OK.html - шаблон для вывода информации об успешном добавлении отчета в БД - ├── report_basic.html - шаблон для ввода параметров просмотра/создания отчёта - └── report_menu.html - шаблон для выбора просмотра/создания отчёта \ No newline at end of file diff --git a/App/Requests/description.txt b/App/Requests/description.txt deleted file mode 100644 index 1b4d300..0000000 --- a/App/Requests/description.txt +++ /dev/null @@ -1,18 +0,0 @@ -. -├── db -│   ├── DBconnect.py - коннектор к СУБД -│   ├── __init__.py - файл для инициализации db как модуль -│   ├── select.py - файл для выполнения select-запросов к СУБД -│   └── sql_provider.py - SQL-провайдер для формирования запроса к СУБД -├── __init__.py - файл для инициализации Requests как модуль -├── requests_model.py - реализация модели варианта работы с запросами -├── sql -│   ├── materials_names.sql - sql-запрос для получения списка материалоа заготовок -│   ├── sellers_names.sql - sql-запрос для получения списка поставщиков -│   ├── ship_seller.sql - sql-запрос для получения списка поставок поставщиком -│   └── sklad_material.sql - sql-запрос для получения списка заготовок на складе -├── templates -│   ├── sellers_ship.html - шаблон для формы передачи параметров для запроса всех поставок выбранного поставщика -│   ├── zagotovki.html - шаблон для формы передачи параметров для запроса количества заготовок на складе -│   └── zapros_menu.html - шаблон для выбора варианта отчёта -└── zapros_menu.json - файл с названиями запросов и их ссылками \ No newline at end of file diff --git a/App/auth.txt b/App/auth.txt new file mode 100644 index 0000000..b51cd9d --- /dev/null +++ b/App/auth.txt @@ -0,0 +1,13 @@ +. +├── Database +│   ├── DBconnect.py - коннектор к СУБД +│   ├── __init__.py +│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД +│   └── work.py - файл для выполнения запросов к СУБД +└── Auth +    ├── auth_model.py - реализация модели авторизации +    ├── __init__.py +    ├── sql +    │   └── auth.sql - sql-запрос, проверяющий наличие пользователя в СУБД +    └── templates +    └── auth.html - шаблон для страницы авторизации diff --git a/App/description.txt b/App/description.txt deleted file mode 100644 index 4c64a2b..0000000 --- a/App/description.txt +++ /dev/null @@ -1,16 +0,0 @@ - -. -├── app.py - основное приложение -├── checker.py - декораторы -├── data -│   ├── config.json - конфигурация для подключения к СУБД -│   └── db_access.json - доступ пользователей к вариантам использования ИС -├── static -│   └── css - стили для страниц -│   ├── auth.css -│   ├── main.css -│   └── output.css -└── templates - ├── error.html - универсальный шаблон для ошибок - ├── main_menu.html - шаблон главного меню - └── output.html - универсальный шаблон для вывода результатов diff --git a/App/main.txt b/App/main.txt new file mode 100644 index 0000000..e565e32 --- /dev/null +++ b/App/main.txt @@ -0,0 +1,19 @@ +. +├── app.py - основное приложение +├── checker.py - декораторы +├── data +│   ├── config.json - конфигурация для подключения к СУБД +│   ├── db_access.json - доступ пользователей к вариантам использования ИС +│   └── redis_config.json - конфигурация для подключения к Redis +├── Database +│   ├── DBconnect.py - коннектор к СУБД +│   ├── __init__.py +│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД +│   └── work.py - файл для выполнения запросов к СУБД +├── static +│   └── css - стили для страниц +│   └── main.css +└── templates - стандартные шаблоны для страниц +    ├── error.html - шаблон для ошибок +    ├── main_menu.html - шаблон главного меню +    └── output.html - шаблон для вывода результатов в формате таблицы diff --git a/App/report.txt b/App/report.txt new file mode 100644 index 0000000..7ae310a --- /dev/null +++ b/App/report.txt @@ -0,0 +1,22 @@ +. +├── Database +│   ├── DBconnect.py - коннектор к СУБД +│   ├── __init__.py +│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД +│   └── work.py - файл для выполнения запросов к СУБД +└── Report +    ├── __init__.py +    ├── report_model.py - реализация модели работы с отчётами +    ├── reports.json - файл с информацией о вариантах отчётов +    ├── sql +    │   ├── sellers_report.sql - sql-запрос для просмотра отчёта о поставках поставщиков +    │ └── workpiece_report.sql - sql-запрос для просмотра отчёта о поставках заготовок +    ├── static +    │   ├── css - стили страниц +    │   │   └── report.css +    │   └── js +    │   └── check.js - проверка периода формирования отчёта +    └── templates +    ├── OK.html - шаблон для вывода информации об успешном добавлении отчета в БД + ├── report_basic.html - шаблон для ввода параметров просмотра/создания отчёта + └── report_menu.html - шаблон для выбора просмотра/создания отчёта \ No newline at end of file diff --git a/App/requests.txt b/App/requests.txt new file mode 100644 index 0000000..3682d42 --- /dev/null +++ b/App/requests.txt @@ -0,0 +1,19 @@ +. +├── Database +│   ├── DBconnect.py - коннектор к СУБД +│   ├── __init__.py +│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД +│   └── work.py - файл для выполнения запросов к СУБД +└── Requests +    ├── __init__.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 - шаблон для формы передачи параметров для запроса всех поставок выбранного поставщика + │   ├── zagotovki.html - шаблон для формы передачи параметров для запроса количества заготовок на складе + │   └── zapros_menu.html - шаблон для выбора варианта отчёта +   └── zapros_menu.json - файл с названиями запросов и их ссылками \ No newline at end of file diff --git a/App/waybill.txt b/App/waybill.txt new file mode 100644 index 0000000..ca0117f --- /dev/null +++ b/App/waybill.txt @@ -0,0 +1,25 @@ +. +├── cache - модуль для кэширования данных +│ ├── __init__.py +│ └── wrapper.py - файл с функцией-обёрткой для кэширования функций +├── Database +│   ├── DBconnect.py - коннектор к СУБД +│   ├── __init__.py +│   ├── sql_provider.py - SQL-провайдер для формирования запроса к СУБД +│   └── work.py - файл для выполнения запросов к СУБД +└── Waybill + ├── __init__.py + ├── model.py - реализация модели оформления накладной + ├── sql + │ ├── create_order.sql - SQL запрос на создание накладной + │ ├── goods.sql - SQL запрос на получение списка заготовок + │ ├── insert_order_line.sql - SQL запрос на добавление позиции в накладную + │ └── one_good.sql - SQL запрос на получение информации о заготовке + ├── static + │ └── css - стили страниц + │ └── waybill.css + └── templates + ├── card.html - шаблон для отображения карточки заготовки + ├── order_finish.html - шаблон для страницы о завершении оформления накладной + └── waybill.html - шаблон для страницы формированиянакладной + From d995a2cc14f9bab38484736953a7d143782e3506 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Fri, 6 Dec 2024 16:14:31 +0300 Subject: [PATCH 15/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=BE=D0=BF=D0=B8=D1=81?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Report/__init__.py | 2 +- App/{ => Report}/static/css/report.css | 0 App/{ => Report}/static/js/check.js | 0 App/Report/templates/report_basic.html | 4 ++-- App/Report/templates/report_menu.html | 2 +- App/static/css/auth.css | 5 ----- App/templates/main_menu.html | 5 ++++- 7 files changed, 8 insertions(+), 10 deletions(-) rename App/{ => Report}/static/css/report.css (100%) rename App/{ => Report}/static/js/check.js (100%) delete mode 100644 App/static/css/auth.css diff --git a/App/Report/__init__.py b/App/Report/__init__.py index 5794625..ee25b68 100644 --- a/App/Report/__init__.py +++ b/App/Report/__init__.py @@ -8,7 +8,7 @@ import json with open(path.join(path.dirname(__file__), 'reports.json'), encoding='utf-8') as f: report_list = json.load(f) -report_bp = Blueprint('report_bp', __name__, template_folder='templates') +report_bp = Blueprint('report_bp', __name__, template_folder='templates', static_folder='static') @report_bp.route('/menu') @check_auth diff --git a/App/static/css/report.css b/App/Report/static/css/report.css similarity index 100% rename from App/static/css/report.css rename to App/Report/static/css/report.css diff --git a/App/static/js/check.js b/App/Report/static/js/check.js similarity index 100% rename from App/static/js/check.js rename to App/Report/static/js/check.js diff --git a/App/Report/templates/report_basic.html b/App/Report/templates/report_basic.html index 03e0f3a..2f79c89 100644 --- a/App/Report/templates/report_basic.html +++ b/App/Report/templates/report_basic.html @@ -4,7 +4,7 @@ {{ title }} - + - +
diff --git a/App/Report/templates/report_menu.html b/App/Report/templates/report_menu.html index d55d621..919bd42 100644 --- a/App/Report/templates/report_menu.html +++ b/App/Report/templates/report_menu.html @@ -29,7 +29,7 @@
diff --git a/App/static/css/auth.css b/App/static/css/auth.css deleted file mode 100644 index 286c3d1..0000000 --- a/App/static/css/auth.css +++ /dev/null @@ -1,5 +0,0 @@ -form[name="auth"] input[type="submit"] { - display: block; - margin: 10px auto; - background-color: #f2c464; -} \ No newline at end of file diff --git a/App/templates/main_menu.html b/App/templates/main_menu.html index 473c62e..0c4fb6c 100644 --- a/App/templates/main_menu.html +++ b/App/templates/main_menu.html @@ -33,8 +33,11 @@
+ {% if 'role' in ses and ses['access_user'] == 'internal_users'%} +

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

+ {% endif %}
-
+
{% if 'role' not in ses %}

Для доступа к функциям системы необходимо авторизоваться