Files
TestingWebApp/flask_app/app/config.py
T
2026-04-29 21:06:17 +05:00

45 lines
1.7 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Точечные настройки и feature-флаги (1:1 с Express-бэкендом)."""
from __future__ import annotations
import os
HR_MANAGED_PASSWORD_PLACEHOLDER = '$HR$MANAGED$NO_LOCAL$'
"""Заглушка пароля для пользователей, попавших в clinic_tests через HR-апсёрт.
При локальном входе compare всегда даёт False (см. authenticate_local)."""
def _truthy(val: str | None) -> bool:
return (val or '').strip().lower() in ('1', 'true', 'yes', 'on')
def is_hr_auth_enabled() -> bool:
"""`HR_AUTH=1` → логин через `hr_bot_test.users` (Werkzeug)."""
return _truthy(os.environ.get('HR_AUTH'))
def is_assignment_feature_enabled() -> bool:
"""API/UI назначения тестов сотрудникам (см. backend/src/config/featureFlags.js)."""
if (os.environ.get('FLASK_ENV') or '').lower() == 'development':
return True
if (os.environ.get('FLASK_DEBUG') or '').strip() == '1':
return True
raw = (os.environ.get('CLINIC_ASSIGNMENT_ENABLED') or '').strip().lower()
if raw in ('1', 'true', 'yes'):
return True
if raw in ('0', 'false', 'no'):
return False
return False
def is_dev_ui() -> bool:
"""В Express это `NODE_ENV=development`. У нас — FLASK_ENV/FLASK_DEBUG."""
if (os.environ.get('FLASK_ENV') or '').lower() == 'development':
return True
return (os.environ.get('FLASK_DEBUG') or '').strip() == '1'
def get_dev_fio_password() -> str | None:
"""Общий пароль для dev-входа по ФИО. Задаётся в DEV_FIO_PASSWORD."""
return os.environ.get('DEV_FIO_PASSWORD') or None