TorbatYar/backend/services/experience/app/commands/localization.py
Mortezakoohjani 203671a7bf feat(experience): ship Experience Platform phases 11.0-11.10
Add the experience service with sites through analytics/AI hooks, migrations through 0011, and phase docs/manifests marking the track complete.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-27 11:43:10 +03:30

109 lines
3.2 KiB
Python

"""Localization & media-ref command handlers — Phase 11.5."""
from __future__ import annotations
from uuid import UUID
from sqlalchemy.ext.asyncio import AsyncSession
from app.schemas.localization import (
ExperienceLocalizationUpdate,
ExperienceLocalizationUpsert,
ExperienceMediaRefCreate,
ExperienceMediaRefUpdate,
SiteLocaleBindingCreate,
SiteLocaleBindingUpdate,
)
from app.services.localization import ExperienceLocalizationService
from shared.security import CurrentUser
class LocalizationCommands:
def __init__(self, session: AsyncSession) -> None:
self.service = ExperienceLocalizationService(session)
async def create_site_locale_binding(
self,
tenant_id: UUID,
body: SiteLocaleBindingCreate,
*,
actor: CurrentUser | None,
):
return await self.service.create_site_locale_binding(
tenant_id, body, actor=actor
)
async def update_site_locale_binding(
self,
tenant_id: UUID,
binding_id: UUID,
body: SiteLocaleBindingUpdate,
*,
actor: CurrentUser | None,
):
return await self.service.update_site_locale_binding(
tenant_id, binding_id, body, actor=actor
)
async def soft_delete_site_locale_binding(
self, tenant_id: UUID, binding_id: UUID, *, actor: CurrentUser | None
):
return await self.service.soft_delete_site_locale_binding(
tenant_id, binding_id, actor=actor
)
async def upsert_localization(
self,
tenant_id: UUID,
body: ExperienceLocalizationUpsert,
*,
actor: CurrentUser | None,
):
return await self.service.upsert_localization(tenant_id, body, actor=actor)
async def update_localization(
self,
tenant_id: UUID,
localization_id: UUID,
body: ExperienceLocalizationUpdate,
*,
actor: CurrentUser | None,
):
return await self.service.update_localization(
tenant_id, localization_id, body, actor=actor
)
async def soft_delete_localization(
self, tenant_id: UUID, localization_id: UUID, *, actor: CurrentUser | None
):
return await self.service.soft_delete_localization(
tenant_id, localization_id, actor=actor
)
async def create_media_ref(
self,
tenant_id: UUID,
body: ExperienceMediaRefCreate,
*,
actor: CurrentUser | None,
):
return await self.service.create_media_ref(tenant_id, body, actor=actor)
async def update_media_ref(
self,
tenant_id: UUID,
media_ref_id: UUID,
body: ExperienceMediaRefUpdate,
*,
actor: CurrentUser | None,
):
return await self.service.update_media_ref(
tenant_id, media_ref_id, body, actor=actor
)
async def soft_delete_media_ref(
self, tenant_id: UUID, media_ref_id: UUID, *, actor: CurrentUser | None
):
return await self.service.soft_delete_media_ref(
tenant_id, media_ref_id, actor=actor
)