Files
RoleForge/app/services/ui_branding.py
Sergey Antropoff 01d598eea5 - Админка: настройка pull-реестра (Hub / Harbor / Nexus) в БД, шифрование секретов;
обновлён /admin/config и API для os_registry.
- Molecule/раннер: env из конфигурации, ensure roleforge-os (ensure_roleforge_os.yml),
  os_registry_pull и доработки executors / runner / create.yml.
- /admin/os-images: выбор реестра, buildx (в т.ч. split amd64+arm64 + imagetools),
  опция --no-cache, стрим логов; domain.py: план команд build, ретраи push.
- UI: брендинг (app_name, app_tagline) из app_config через get_ui_branding_context;
  base.xhtml, role-create / role-view, core.js, pages-main, стили.
- Dockerfiles: требование Python ≥3.9 (assert), доработки alt9/astra/debian9/ubuntu20
  и др.; новые Dockerfile.arm64 для centos7/centos8.
- Конфиг: .env.example, config.py, pyproject.toml.
2026-05-06 07:52:29 +03:00

46 lines
1.5 KiB
Python

"""Sidebar / document title branding from app_config.project (app_name, app_tagline)."""
from __future__ import annotations
import json
from typing import Any
from app.core.config import get_settings
from app.db.pool import get_pool
def _decode_config_value(raw: Any) -> dict[str, Any]:
if raw is None:
return {}
if isinstance(raw, dict):
return dict(raw)
if isinstance(raw, str):
try:
parsed = json.loads(raw)
return dict(parsed) if isinstance(parsed, dict) else {}
except (json.JSONDecodeError, TypeError, ValueError):
return {}
return {}
async def get_ui_branding_context() -> dict[str, str]:
settings = get_settings()
default_name = (settings.app_name or "RoleForge").strip() or "RoleForge"
default_tagline = (settings.app_tagline or "Ansible Orchestrator").strip() or "Ansible Orchestrator"
saved: dict[str, Any] = {}
try:
pool = get_pool()
async with pool.acquire() as conn:
row = await conn.fetchrow("select value from app_config where key = $1", "project")
if row is not None:
saved = _decode_config_value(row["value"])
except Exception: # noqa: BLE001
saved = {}
name = saved.get("app_name")
tag = saved.get("app_tagline")
brand_name = str(name).strip() if name not in (None, "") else default_name
brand_tagline = str(tag).strip() if tag not in (None, "") else default_tagline
return {"brand_name": brand_name, "brand_tagline": brand_tagline}