generated from coulomb/repo-seed
Close lifecycle transition helper workplan
This commit is contained in:
@@ -16,9 +16,10 @@ from api.flow_defs import (
|
||||
)
|
||||
from api.models.capability_request import CapabilityRequest
|
||||
from api.models.contribution import Contribution
|
||||
from api.models.task import Task
|
||||
from api.models.task import Task, TaskStatus
|
||||
from api.models.workstream import Workstream
|
||||
from api.models.workstream_dependency import WorkstreamDependency
|
||||
from api.services.lifecycle import transition_task_status, transition_workstream_status
|
||||
from api.workplan_status import normalize_workstream_status
|
||||
|
||||
router = APIRouter(prefix="/flows", tags=["flows"])
|
||||
@@ -92,7 +93,18 @@ async def advance_workstation(
|
||||
)
|
||||
|
||||
entity = await _entity(entity_type, entity_id, session)
|
||||
entity.status = target_workstation
|
||||
if entity_type == "workstream":
|
||||
transition_workstream_status(entity, target_workstation)
|
||||
elif entity_type == "task":
|
||||
parent = await session.get(Workstream, entity.workstream_id)
|
||||
transition_task_status(
|
||||
entity,
|
||||
target_workstation,
|
||||
parent_workstream=parent,
|
||||
status_coercer=TaskStatus,
|
||||
)
|
||||
else:
|
||||
entity.status = target_workstation
|
||||
await session.commit()
|
||||
await session.refresh(entity)
|
||||
return await get_flow_state(entity_type, entity_id, session)
|
||||
|
||||
Reference in New Issue
Block a user