Fix: accept task_code/milestone_code as identifiers, add /config/status endpoint

- All /tasks/{task_id} endpoints now accept both numeric id and task_code string
- All /milestones/{milestone_id} endpoints (misc.py) now accept both numeric id and milestone_code
- Added _resolve_task() and _resolve_milestone() helpers
- GET /config/status reads initialization state from config volume (no wizard dependency)
- MilestoneResponse schema now includes milestone_code field
- Comments and worklog endpoints also accept task_code
This commit is contained in:
zhi
2026-03-22 10:06:27 +00:00
parent 271d5140e6
commit 8b357aabc4
5 changed files with 104 additions and 57 deletions

View File

@@ -51,8 +51,16 @@ def create_comment(comment: schemas.CommentCreate, db: Session = Depends(get_db)
@router.get("/tasks/{task_id}/comments", response_model=List[schemas.CommentResponse])
def list_comments(task_id: int, db: Session = Depends(get_db)):
return db.query(models.Comment).filter(models.Comment.task_id == task_id).all()
def list_comments(task_id: str, db: Session = Depends(get_db)):
"""List comments for a task. task_id can be numeric id or task_code."""
try:
tid = int(task_id)
except (ValueError, TypeError):
task = db.query(Task).filter(Task.task_code == task_id).first()
if not task:
raise HTTPException(status_code=404, detail="Task not found")
tid = task.id
return db.query(models.Comment).filter(models.Comment.task_id == tid).all()
@router.patch("/comments/{comment_id}", response_model=schemas.CommentResponse)