feat: delete & archive projects

This commit is contained in:
ivannoskov
2026-01-07 17:32:20 +03:00
parent 89f4d6bf69
commit 30791d7f76
9 changed files with 128 additions and 8 deletions

View File

@@ -0,0 +1,32 @@
import uuid
from typing import TYPE_CHECKING
from src import domain, dto
if TYPE_CHECKING:
from .. import Usecase
async def archive_project(self: 'Usecase', input: dto.ArchiveProjectInput) -> dto.ProjectOutput:
await self.ensure_workspace_permission(
input.workspace_id, input.user_id, domain.PermissionKey.PROJECTS_WRITE, for_project_id=input.project_id
)
async with self.database.transaction():
await self.database.archive_project(input.workspace_id, input.project_id)
project = await self.database.get_project(input.workspace_id, project_id=input.project_id)
if not project:
raise domain.ProjectNotFound()
await project.fetch_related('channel')
return dto.ProjectOutput(
id=project.id,
telegram_id=project.channel.telegram_id,
title=project.channel.title,
username=project.channel.username,
status=project.status,
purchase_invite_type_default=project.purchase_invite_type_default,
)