feat(backend): drop dictionary dialect columns, add allowed_languages

- Removes source_dialect and target_dialect from TerminologyDictionary model,
  schemas, routes, helper serialization, and all tests
- Adds allowed_languages config field (BCP-47 language codes) to GlobalSettings
  with validation, consolidated settings response, and API endpoint
- Adds alembic migration f1a2b3c4d5e6 to drop the two columns
This commit is contained in:
2026-06-03 11:48:03 +03:00
parent 236dadb914
commit 1e6ec34c2b
15 changed files with 129 additions and 67 deletions

View File

@@ -128,6 +128,22 @@ async def get_features(
# #endregion get_features
# #region get_allowed_languages [C:1] [TYPE Function]
# @BRIEF Public endpoint returning allowed translation languages for language dropdowns.
# @RATIONALE No auth required — needed by dictionary page, job config, etc. everywhere
# language selects appear. Non-admin users still need the list.
# @PRE Config manager is available.
# @POST Returns list of BCP-47 language codes.
@router.get("/allowed-languages")
async def get_allowed_languages(
config_manager: ConfigManager = Depends(get_config_manager),
):
return config_manager.get_config().settings.allowed_languages
# #endregion get_allowed_languages
# #region update_global_settings [C:2] [TYPE Function]
# @BRIEF Updates global application settings.
# @PRE New settings are provided.
@@ -394,6 +410,7 @@ class ConsolidatedSettingsResponse(BaseModel):
notifications: dict = {}
features: dict = {}
app_timezone: str = "Europe/Moscow"
allowed_languages: list[str] = []
# #endregion ConsolidatedSettingsResponse
@@ -465,6 +482,7 @@ async def get_consolidated_settings(
notifications=notifications_payload,
features=config.settings.features.model_dump(),
app_timezone=config.settings.app_timezone,
allowed_languages=config.settings.allowed_languages,
)
logger.reflect(
"Consolidated settings payload assembled",
@@ -537,6 +555,10 @@ async def update_consolidated_settings(
current_settings.app_timezone = new_tz
invalidate_timezone_cache()
# Update allowed_languages if provided
if "allowed_languages" in settings_patch:
current_settings.allowed_languages = settings_patch["allowed_languages"]
config_manager.update_global_settings(current_settings)
return {"status": "success", "message": "Settings updated"}