Files
tgex-backend/src/usecase/creative/get_creatives.py

31 lines
937 B
Python

from typing import TYPE_CHECKING
from src import dto
if TYPE_CHECKING:
from .. import Usecase
async def get_creatives(self: 'Usecase', input: dto.GetCreativesInput) -> dto.GetCreativesOutput:
await self.ensure_workspace_access(input.workspace_id, input.user_id)
creatives = await self.database.get_workspace_creatives(
input.workspace_id, input.project_id, input.include_archived
)
return dto.GetCreativesOutput(
creatives=[
dto.CreativeOutput(
id=creative.id,
name=creative.name,
text=creative.text,
project_id=creative.project_id,
project_channel_title=creative.project.channel.title,
created_at=creative.created_at,
status=creative.status,
placements_count=creative.placements_count,
)
for creative in creatives
]
)