BE-PR-008: add Proposal Accept tracking fields (source_proposal_id, source_essential_id)
- Add source_proposal_id and source_essential_id FK columns to Task model - Populate tracking fields during Proposal Accept task generation - Add generated_tasks relationship on Proposal model for reverse lookup - Expose source_proposal_id/source_essential_id in TaskResponse schema - Add GeneratedTaskBrief schema and include generated_tasks in ProposalDetailResponse - Proposal detail endpoint now returns generated story tasks with status
This commit is contained in:
@@ -63,6 +63,26 @@ def _serialize_proposal(db: Session, proposal: Proposal, *, include_essentials:
|
||||
.all()
|
||||
)
|
||||
result["essentials"] = [_serialize_essential(e) for e in essentials]
|
||||
|
||||
# BE-PR-008: include tasks generated from this Proposal via Accept
|
||||
gen_tasks = (
|
||||
db.query(Task)
|
||||
.filter(Task.source_proposal_id == proposal.id)
|
||||
.order_by(Task.id.asc())
|
||||
.all()
|
||||
)
|
||||
result["generated_tasks"] = [
|
||||
{
|
||||
"task_id": t.id,
|
||||
"task_code": t.task_code,
|
||||
"task_type": t.task_type or "story",
|
||||
"task_subtype": t.task_subtype,
|
||||
"title": t.title,
|
||||
"status": t.status.value if hasattr(t.status, "value") else t.status,
|
||||
"source_essential_id": t.source_essential_id,
|
||||
}
|
||||
for t in gen_tasks
|
||||
]
|
||||
return result
|
||||
|
||||
|
||||
@@ -327,6 +347,9 @@ def accept_proposal(
|
||||
reporter_id=proposal.created_by_id or current_user.id,
|
||||
created_by_id=proposal.created_by_id or current_user.id,
|
||||
task_code=task_code,
|
||||
# BE-PR-008: track which Proposal/Essential generated this task
|
||||
source_proposal_id=proposal.id,
|
||||
source_essential_id=essential.id,
|
||||
)
|
||||
db.add(task)
|
||||
db.flush() # materialise task.id
|
||||
|
||||
Reference in New Issue
Block a user