mirror of
https://github.com/wizarrrr/wizarr.git
synced 2026-04-21 22:48:45 -04:00
- Fix 55 test failures caused by missing request contexts and incorrect session_transaction() usage across 8 test files - Fix ruff import sorting errors and unused imports - Fix 122 type errors: rename method override parameters to match base classes, add None guards for fetchone()/datetime, widen dict type annotations, add type: ignore for SQLAlchemy stub limitations - Add [tool.ty.rules] config to suppress unsupported-base warnings - Fix _ variable shadowing gettext in wizard routes - Add noqa: ARG002 for unused method arguments required by base class
33 lines
1008 B
Python
33 lines
1008 B
Python
from app.extensions import db
|
|
from app.models import Settings
|
|
|
|
|
|
def inject_server_name():
|
|
from sqlalchemy.exc import OperationalError, PendingRollbackError
|
|
|
|
try:
|
|
# Use no_autoflush to prevent triggering pending session changes
|
|
with db.session.no_autoflush:
|
|
setting = Settings.query.filter_by(key="server_name").first()
|
|
server_name = setting.value if setting else "Wizarr"
|
|
except (OperationalError, PendingRollbackError) as e:
|
|
if "database is locked" in str(e).lower():
|
|
# Fallback to default if database is locked
|
|
server_name = "Wizarr"
|
|
else:
|
|
raise
|
|
|
|
return {"server_name": server_name}
|
|
|
|
|
|
def inject_plus_features():
|
|
"""Inject Plus features availability into template context."""
|
|
try:
|
|
import plus
|
|
|
|
is_plus_enabled = plus.is_plus_enabled() # type: ignore
|
|
except (ImportError, AttributeError):
|
|
is_plus_enabled = False
|
|
|
|
return {"is_plus_enabled": is_plus_enabled}
|