From f9ea3c56cd99937bc4b63abd68547e78775f3ef5 Mon Sep 17 00:00:00 2001 From: Anton Kamalov Date: Tue, 5 Nov 2024 15:46:40 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0=D1=82=D0=B5?= =?UTF-8?q?=D0=BB=D1=8F=20+=20=D0=BA=D0=BE=D1=80=D1=80=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D1=81=D0=BE=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B6=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=BC=D0=BE=D0=B4=D1=83?= =?UTF-8?q?=D0=BB=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App/Auth/{auth.py => __init__.py} | 1 + App/Requests/{requests.py => __init__.py} | 6 +----- App/app.py | 8 +++----- App/checker.py | 7 ------- App/data/db_access.json | 4 ++-- App/templates/exit.html | 12 ------------ App/templates/main_menu.html | 17 +++++++++++++---- 7 files changed, 20 insertions(+), 35 deletions(-) rename App/Auth/{auth.py => __init__.py} (93%) rename App/Requests/{requests.py => __init__.py} (96%) delete mode 100644 App/templates/exit.html diff --git a/App/Auth/auth.py b/App/Auth/__init__.py similarity index 93% rename from App/Auth/auth.py rename to App/Auth/__init__.py index 044accb..4d4ad1e 100644 --- a/App/Auth/auth.py +++ b/App/Auth/__init__.py @@ -16,6 +16,7 @@ def auth(): 'login': auth_data.result[0]['login'], '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/Requests/requests.py b/App/Requests/__init__.py similarity index 96% rename from App/Requests/requests.py rename to App/Requests/__init__.py index 0e6e5c7..ae32219 100644 --- a/App/Requests/requests.py +++ b/App/Requests/__init__.py @@ -1,6 +1,6 @@ from flask import request, Blueprint, render_template from os import path -from checker import check_auth, group_required +from checker import check_auth from .requests_model import sklad, get_goods, get_sellers, materials_per_seller from datetime import date import json @@ -12,14 +12,12 @@ requests_bp = Blueprint('requests_bp', __name__, template_folder='templates') @requests_bp.route('/', methods=['GET', 'POST']) @check_auth -@group_required def requests(): if request.method == 'GET': return render_template('zapros_menu.html', options=requests_list) @requests_bp.route('/sklad', methods=['GET', 'POST']) @check_auth -@group_required def sklad_zapros(): if request.method == 'GET': zagotovki = get_goods() @@ -39,7 +37,6 @@ def sklad_zapros(): # Под вопросом """ @requests_bp.route('/req2', methods=['GET', 'POST']) @check_auth -@group_required def zagotovki_ship(): if request.method == 'GET': zagotovki = get_goods() @@ -58,7 +55,6 @@ def zagotovki_ship(): @requests_bp.route('/shipments', methods=['GET', 'POST']) @check_auth -@group_required def sellers_ship(): if request.method == 'GET': zagotovki = get_sellers() diff --git a/App/app.py b/App/app.py index d70d835..2941e4a 100644 --- a/App/app.py +++ b/App/app.py @@ -1,7 +1,6 @@ from flask import Flask, render_template, session -from Requests.requests import requests_bp -from Auth.auth import auth_bp -from checker import check_auth +from Requests import requests_bp +from Auth import auth_bp import os, json app = Flask(__name__) @@ -20,8 +19,7 @@ def index(): return render_template('main_menu.html', ses=session) @app.route('/logout') -@check_auth def logout(): session.clear() - return render_template('exit.html') + return render_template('main_menu.html', ses=session) app.run(port=5001, debug=True) \ No newline at end of file diff --git a/App/checker.py b/App/checker.py index e7f61d9..343d9b2 100644 --- a/App/checker.py +++ b/App/checker.py @@ -7,12 +7,6 @@ def check_auth(func): def wrapper(*args, **kwargs): if 'login' not in session: return redirect(url_for('auth_bp.auth')) - return func(*args, **kwargs) - return wrapper - -def group_required(func): - @wraps(func) - def wrapper(*args, **kwargs): user_role = session.get('role') user_request = request.endpoint print('request_endpoint=', user_request) @@ -22,5 +16,4 @@ def group_required(func): return func(*args, **kwargs) else: return render_template('error.html', error_message='Недостаточно прав') - return wrapper \ No newline at end of file diff --git a/App/data/db_access.json b/App/data/db_access.json index a45fba0..89e568d 100644 --- a/App/data/db_access.json +++ b/App/data/db_access.json @@ -1,5 +1,5 @@ { "manager": ["auth_bp", "requests_bp"], - "admin": ["auth_bp", "requests_bp"], - "sellers": ["auth_bp", "requests_bp"] + "boss": ["auth_bp", "requests_bp"], + "sellers": ["auth_bp", "requests_bp", "waybill_bp"] } \ No newline at end of file diff --git a/App/templates/exit.html b/App/templates/exit.html deleted file mode 100644 index 0973b70..0000000 --- a/App/templates/exit.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - Успешно - - - -

До свидания!

- - - \ No newline at end of file diff --git a/App/templates/main_menu.html b/App/templates/main_menu.html index 622e6f7..8e0a049 100644 --- a/App/templates/main_menu.html +++ b/App/templates/main_menu.html @@ -11,15 +11,24 @@

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

+ {% if ses['access_user'] == 'in' %} + + + {% else %} + + {% endif %} {% else %}

Здравствуйте!

+

Для использования системы, пожалуйста, пройдите процедуру авторизации

{% endif %} - - \ No newline at end of file