generated from coulomb/repo-seed
Close lifecycle transition helper workplan
This commit is contained in:
@@ -19,6 +19,7 @@ from api.schemas.workstream import (
|
||||
WorkstreamRead,
|
||||
WorkstreamUpdate,
|
||||
)
|
||||
from api.services.lifecycle import transition_workstream_status
|
||||
from api.workplan_status import (
|
||||
is_supported_workstream_status,
|
||||
normalize_workstream_status,
|
||||
@@ -184,9 +185,13 @@ async def update_workstream(
|
||||
ws = await session.get(Workstream, workstream_id)
|
||||
if ws is None:
|
||||
raise HTTPException(status_code=404, detail="Workstream not found")
|
||||
update_data = body.model_dump(exclude_unset=True)
|
||||
status_update = update_data.pop("status", None)
|
||||
prev_status = ws.status
|
||||
for field, value in body.model_dump(exclude_unset=True).items():
|
||||
for field, value in update_data.items():
|
||||
setattr(ws, field, value)
|
||||
if status_update is not None:
|
||||
transition_workstream_status(ws, status_update)
|
||||
await session.commit()
|
||||
await session.refresh(ws)
|
||||
|
||||
@@ -216,7 +221,7 @@ async def archive_workstream(
|
||||
ws = await session.get(Workstream, workstream_id)
|
||||
if ws is None:
|
||||
raise HTTPException(status_code=404, detail="Workstream not found")
|
||||
ws.status = "archived"
|
||||
transition_workstream_status(ws, "archived")
|
||||
await session.commit()
|
||||
await session.refresh(ws)
|
||||
return ws
|
||||
|
||||
Reference in New Issue
Block a user