feat: полный patch External Channel архивирование creative в patch и
purchase, удалить у них доп ручки/usecase/dto
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
import logging
|
||||
import uuid
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from src import domain, dto
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .. import Usecase
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def archive_purchase(self: 'Usecase', purchase_id: uuid.UUID, user_id: uuid.UUID) -> dto.PurchaseOutput:
|
||||
async with self.database.transaction():
|
||||
purchase = await self.database.get_purchase(user_id, purchase_id)
|
||||
if not purchase:
|
||||
log.warning('Purchase %s not found for user %s', purchase_id, user_id)
|
||||
raise domain.PurchaseNotFound(purchase_id)
|
||||
|
||||
purchase.status = domain.PurchaseStatus.ARCHIVED
|
||||
updated = await self.database.update_purchase(purchase)
|
||||
|
||||
return dto.PurchaseOutput(
|
||||
id=updated.id,
|
||||
target_channel_id=updated.target_channel_id,
|
||||
target_channel_title=updated.target_channel.title,
|
||||
external_channel_id=updated.external_channel_id,
|
||||
external_channel_title=updated.external_channel.title,
|
||||
creative_id=updated.creative_id,
|
||||
creative_name=updated.creative.name,
|
||||
placement_date=updated.placement_date,
|
||||
cost=updated.cost,
|
||||
comment=updated.comment,
|
||||
ad_post_url=updated.ad_post_url,
|
||||
invite_link_type=updated.invite_link_type,
|
||||
invite_link=updated.invite_link,
|
||||
status=updated.status,
|
||||
subscriptions_count=updated.subscriptions_count,
|
||||
views_count=updated.views_count,
|
||||
views_availability=updated.views_availability,
|
||||
last_views_fetch_at=updated.last_views_fetch_at,
|
||||
created_at=updated.created_at,
|
||||
)
|
||||
@@ -28,6 +28,8 @@ async def update_purchase(
|
||||
purchase.comment = input.comment
|
||||
if input.ad_post_url is not None:
|
||||
purchase.ad_post_url = input.ad_post_url
|
||||
if input.status is not None:
|
||||
purchase.status = input.status
|
||||
|
||||
updated = await self.database.update_purchase(purchase)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user