mirror of
https://github.com/velocitatem/cvfs.git
synced 2026-05-31 08:43:37 +00:00
feat: add mobile support, delete CV/branch, and fix DOCX export with patches
Agent-Logs-Url: https://github.com/velocitatem/cvfs/sessions/4d754ed6-7f63-44e0-8689-123d7a70595f Co-authored-by: velocitatem <60182044+velocitatem@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
300a577fbe
commit
5d815cd24d
@@ -82,3 +82,28 @@ async def create_branch(
|
||||
)
|
||||
result = await session.execute(stmt_refresh)
|
||||
return result.scalars().one()
|
||||
|
||||
|
||||
async def delete_version(
|
||||
session: AsyncSession, owner_id: str, version_id: str
|
||||
) -> bool | str:
|
||||
"""Delete a non-root branch. Returns False if not found, 'root' if root, True on success."""
|
||||
stmt = (
|
||||
select(CvVersion)
|
||||
.join(CvVersion.document)
|
||||
.where(CvVersion.id == version_id, CvDocument.owner_id == owner_id)
|
||||
)
|
||||
result = await session.execute(stmt)
|
||||
version = result.scalars().one_or_none()
|
||||
if not version:
|
||||
return False
|
||||
if not version.parent_version_id:
|
||||
return "root"
|
||||
# Refuse if child branches exist
|
||||
child_stmt = select(CvVersion.id).where(CvVersion.parent_version_id == version_id).limit(1)
|
||||
child_result = await session.execute(child_stmt)
|
||||
if child_result.scalar_one_or_none():
|
||||
return "has_children"
|
||||
await session.delete(version)
|
||||
await session.commit()
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user