This commit is contained in:
Artem Tsyrulnikov
2026-01-15 22:02:16 +03:00
parent 6ec26c96e3
commit 049024ebe8
72 changed files with 2417 additions and 2054 deletions

View File

@@ -0,0 +1,35 @@
import logging
from typing import TYPE_CHECKING
from src import domain, dto
from .create_placements import _build_placement_output
if TYPE_CHECKING:
from .. import Usecase
log = logging.getLogger(__name__)
async def get_placement_user(self: 'Usecase', input: dto.GetPlacementInput) -> dto.PlacementOutput:
"""Get single placement by ID (user-managed)"""
context = await self.ensure_workspace_permission(
input.workspace_id, input.user_id, domain.PermissionKey.PLACEMENTS_READ
)
project = await self.database.get_project(input.workspace_id, project_id=input.project_id)
if not project:
raise domain.ProjectNotFound(input.project_id)
context.ensure_project_permission(domain.PermissionKey.PLACEMENTS_READ, project.id)
placement = await self.database.get_placement(input.workspace_id, input.placement_id)
if not placement or placement.project_id != project.id:
raise domain.PlacementNotFound(input.placement_id)
# Prefetch channel for output building
if placement.channel is None:
channel = await self.database.get_channel(channel_id=placement.channel_id)
placement.channel = channel
return _build_placement_output(placement)