Replace bracket detail page with /jobs?bracket_id= filter
- Bracket names in the list now link directly to /jobs?bracket_id=X
- /brackets/{id} redirects to /jobs?bracket_id=X (keeps old links working)
- Bracket link on job detail page updated accordingly
- bracket_detail.html and add_jobs_to_bracket route removed
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -308,58 +308,9 @@ def create_bracket(
|
||||
return RedirectResponse(url="/brackets", status_code=HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
@router.get("/brackets/{bracket_id}", response_class=HTMLResponse)
|
||||
def bracket_detail(bracket_id: int, request: Request, db: Session = Depends(get_db)):
|
||||
from fastapi import HTTPException
|
||||
bracket = db.query(JobBracket).filter(JobBracket.id == bracket_id).first()
|
||||
if not bracket:
|
||||
raise HTTPException(status_code=404, detail="Bracket not found")
|
||||
return templates.TemplateResponse("bracket_detail.html", {
|
||||
"request": request,
|
||||
"active": "brackets",
|
||||
"bracket": bracket,
|
||||
"stl_files": (stl_files := list_stl_files()),
|
||||
"stl_cache": get_cache_map(stl_files, db),
|
||||
"materials": available_materials() or MATERIALS,
|
||||
"colors": available_colors() or COLORS,
|
||||
})
|
||||
|
||||
|
||||
@router.post("/brackets/{bracket_id}/jobs")
|
||||
async def add_jobs_to_bracket(
|
||||
bracket_id: int,
|
||||
quantity: int = Form(1),
|
||||
job_material: str = Form(""),
|
||||
job_color: str = Form(""),
|
||||
notes: str = Form(""),
|
||||
stl_file: UploadFile = File(None),
|
||||
stl_select: str = Form(""),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
filename = None
|
||||
if stl_file and stl_file.filename:
|
||||
filename = stl_file.filename
|
||||
(get_stl_dir() / filename).write_bytes(await stl_file.read())
|
||||
analyse(filename, db)
|
||||
elif stl_select:
|
||||
filename = stl_select
|
||||
|
||||
for _ in range(max(1, min(quantity, 500))):
|
||||
job = PrintJob(
|
||||
job_uuid=str(_uuid.uuid4()),
|
||||
name=Path(filename).stem if filename else "Unnamed",
|
||||
file_name=filename,
|
||||
bracket_id=bracket_id,
|
||||
job_material=job_material or None,
|
||||
job_color=job_color or None,
|
||||
notes=notes.strip() or None,
|
||||
)
|
||||
db.add(job)
|
||||
db.flush()
|
||||
db.add(JobLog(job_id=job.id, message="Job created"))
|
||||
|
||||
db.commit()
|
||||
return RedirectResponse(url=f"/brackets/{bracket_id}", status_code=HTTP_303_SEE_OTHER)
|
||||
@router.get("/brackets/{bracket_id}")
|
||||
def bracket_detail_redirect(bracket_id: int):
|
||||
return RedirectResponse(url=f"/jobs?bracket_id={bracket_id}", status_code=HTTP_303_SEE_OTHER)
|
||||
|
||||
|
||||
# ── To-Do ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user