From 3a42cd39c255393772997ac59f1374fa40bcdf98 Mon Sep 17 00:00:00 2001 From: RGalyaviev Date: Thu, 4 Sep 2025 17:04:18 +0300 Subject: [PATCH] =?UTF-8?q?chore(ui):=20remove=20'MONT=20=D0=9E=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D1=81=D0=BD=D0=B8=D0=BA'=20label=20near=20logo=20i?= =?UTF-8?q?n=20layout?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 14 ++++++++ templates/layout.html | 80 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/main.py b/main.py index 2a0c78d..dc86ec0 100644 --- a/main.py +++ b/main.py @@ -9,6 +9,7 @@ from email.mime.text import MIMEText import datetime import json from playhouse.shortcuts import model_to_dict +from functools import wraps app = Flask(__name__) @@ -76,6 +77,19 @@ if os.environ.get('SEED_TEST_USERS_DISABLED') != '1': ensure_test_users() +# Admin-only decorator must be defined before routes that use it +def admin_required(f): + @wraps(f) + def decorated_function(*args, **kwargs): + if not current_user.is_authenticated: + return redirect(url_for('login')) + if not getattr(current_user, 'is_admin', False): + flash('Недостаточно прав', 'danger') + return redirect(url_for('dashboard')) + return f(*args, **kwargs) + return decorated_function + + @app.route('/admin/users', methods=['GET', 'POST']) @admin_required def manage_users(): diff --git a/templates/layout.html b/templates/layout.html index c793e4b..48413d6 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -1,59 +1,57 @@ - - {{ title or "Опросник" }} - - - - - + + {{ title or "Опросник" }} + + + + + - - - +
+ {% block content %}{% endblock %} + {% with messages = get_flashed_messages(with_categories=true) %} + {% if messages %} +
+ {% for category, message in messages %} +
{{ message }}
+ {% endfor %} +
+ {% endif %} + {% endwith %} +
+ +