Close lifecycle transition helper workplan
This commit is contained in:
parent
ab23ef4f1f
commit
0ea46f081c
8 changed files with 221 additions and 19 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue