fix: empty project dropdown in pending-deployment classify modal
The classify modal's _loadProjects() fetched /api/projects/list and called .json() on it, but that endpoint returns HTML project cards (used by the projects overview via htmx). Parsing HTML as JSON threw, the catch swallowed it, and the Project dropdown came up empty — so deployments couldn't be assigned to a project. - Add GET /api/projects/list-json returning assignable projects (id, name, status) as JSON, excluding deleted/archived/completed to match the default /list view. - Point the modal's _loadProjects() at the JSON endpoint. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -404,6 +404,26 @@ def _build_combined_location_data(
|
||||
# Project List & Overview
|
||||
# ============================================================================
|
||||
|
||||
@router.get("/list-json")
|
||||
async def get_projects_list_json(db: Session = Depends(get_db)):
|
||||
"""JSON list of assignable projects (id, name, status) for pickers such as
|
||||
the pending-deployment classify modal. Excludes deleted/archived/completed,
|
||||
matching the default /list view. (The /list endpoint returns HTML cards, so
|
||||
JSON consumers must use this one.)"""
|
||||
projects = (
|
||||
db.query(Project)
|
||||
.filter(Project.status.notin_(["deleted", "archived", "completed"]))
|
||||
.order_by(Project.name)
|
||||
.all()
|
||||
)
|
||||
return JSONResponse({
|
||||
"projects": [
|
||||
{"id": p.id, "name": p.name, "status": p.status}
|
||||
for p in projects
|
||||
]
|
||||
})
|
||||
|
||||
|
||||
@router.get("/list", response_class=HTMLResponse)
|
||||
async def get_projects_list(
|
||||
request: Request,
|
||||
|
||||
Reference in New Issue
Block a user