правки

This commit is contained in:
Artem Tsyrulnikov
2026-02-03 14:12:23 +03:00
parent 791f0ad5c0
commit 26a5792665
5 changed files with 62 additions and 101 deletions

View File

@@ -81,7 +81,6 @@ class CreatePlacementsInput(pydantic.BaseModel):
creative_id: uuid.UUID | None = None
channels: list[CreatePlacementChannelInput]
details: PlacementDetails | None = None # Общие детали для всех placements
class GetPlacementsInput(pydantic.BaseModel):

View File

@@ -178,7 +178,6 @@ async def create_placements(
if project.channel.telegram_id is None:
raise domain.ChannelNotFound(project.channel.id)
details = input.details
placements: list[domain.Placement] = []
creatives_by_id: dict[uuid.UUID, domain.Creative] = {}
@@ -187,11 +186,9 @@ async def create_placements(
if not channel:
raise domain.ChannelNotFound(channel_input.channel_id)
# Объединяем общие детали с деталями конкретного канала
channel_details = channel_input.details
creative_id = (
(channel_details.creative_id if channel_details and channel_details.creative_id else None)
or (details.creative_id if details and details.creative_id else None)
or input.creative_id
)
@@ -211,34 +208,30 @@ async def create_placements(
channel_id=channel.id,
invite_link=None,
invite_link_type=(
channel_details.invite_link_type if channel_details and channel_details.invite_link_type else None
channel_details.invite_link_type
if channel_details and channel_details.invite_link_type
else None
)
or (details.invite_link_type if details and details.invite_link_type else None)
or project.purchase_invite_type_default,
status=channel_input.status or domain.PlacementStatus.NO_STATUS,
comment=channel_input.comment,
# Приоритет: channel details > общие details
placement_at=(channel_details.placement_at if channel_details else None)
or (details.placement_at if details else None),
payment_at=details.payment_at if details else None,
cost_type=(channel_details.cost.type if channel_details and channel_details.cost else None)
or (details.cost.type if details and details.cost else None),
cost_value=(channel_details.cost.value if channel_details and channel_details.cost else None)
or (details.cost.value if details and details.cost else None),
comment=channel_input.comment
or (channel_details.comment if channel_details else None),
placement_at=channel_details.placement_at if channel_details else None,
payment_at=channel_details.payment_at if channel_details else None,
cost_type=channel_details.cost.type if channel_details and channel_details.cost else None,
cost_value=channel_details.cost.value if channel_details and channel_details.cost else None,
cost_before_bargain_type=(
channel_details.cost_before_bargain.type
if channel_details and channel_details.cost_before_bargain
else None
)
or (details.cost_before_bargain.type if details and details.cost_before_bargain else None),
),
cost_before_bargain=(
channel_details.cost_before_bargain.value
if channel_details and channel_details.cost_before_bargain
else None
)
or (details.cost_before_bargain.value if details and details.cost_before_bargain else None),
placement_type=details.placement_type if details else None,
format=(channel_details.format if channel_details else None) or (details.format if details else None),
),
placement_type=channel_details.placement_type if channel_details else None,
format=channel_details.format if channel_details else None,
)
await self.database.create_placement(placement)