From 3f40a6126c1ed723b4b2a1348ef31a79842bb39c Mon Sep 17 00:00:00 2001 From: Marcin-Ramotowski Date: Wed, 11 Jun 2025 20:04:04 +0000 Subject: [PATCH] Added more descriptions of functions --- api/utils.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/utils.py b/api/utils.py index e1256a4..2a1261e 100644 --- a/api/utils.py +++ b/api/utils.py @@ -9,13 +9,14 @@ from werkzeug.security import generate_password_hash def admin_required(user_id, message='Access denied.'): + "Check if common user try to make administrative action." user = db.session.get(User, user_id) if user is None or user.role != "Administrator": abort(403, message) def validate_access(owner_id, message='Access denied.'): - # Check if user try to access or edit resource that does not belong to them + "Check if user try to access or edit resource that does not belong to them." logged_user_id = int(get_jwt_identity()) logged_user_role = db.session.get(User, logged_user_id).role if logged_user_role != "Administrator" and logged_user_id != owner_id: @@ -31,6 +32,7 @@ def get_user_or_404(user_id): def wait_for_db(max_retries): + "Try to connect with database times." for _ in range(max_retries): try: with db.engine.connect() as connection: