Show bracket gross total price on bracket filter view
Sums gross_price estimates for all bracket jobs with known STL volume and displays it as a badge next to the bracket name. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -163,6 +163,21 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str
|
||||
)
|
||||
jobs = query.order_by(status_order, PrintJob.priority.desc(), PrintJob.created_at.asc()).all()
|
||||
|
||||
stl_files = list_stl_files()
|
||||
stl_cache = get_cache_map(stl_files, db)
|
||||
|
||||
bracket_gross_total = None
|
||||
if active_bracket:
|
||||
total = 0.0
|
||||
has_any = False
|
||||
for j in active_bracket.jobs:
|
||||
cached = stl_cache.get(j.file_name)
|
||||
if cached and cached.volume_ccm:
|
||||
total += estimate(cached.volume_ccm, j.job_material)["gross_price"]
|
||||
has_any = True
|
||||
if has_any:
|
||||
bracket_gross_total = round(total, 2)
|
||||
|
||||
return templates.TemplateResponse("jobs.html", {
|
||||
"request": request,
|
||||
"active": "jobs",
|
||||
@@ -172,10 +187,11 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str
|
||||
"show_all": bool(show_all),
|
||||
"hidden_count": hidden_count,
|
||||
"active_bracket": active_bracket,
|
||||
"bracket_gross_total": bracket_gross_total,
|
||||
"printers": db.query(Printer).order_by(Printer.name).all(),
|
||||
"brackets": db.query(JobBracket).order_by(JobBracket.name).all(),
|
||||
"stl_files": (stl_files := list_stl_files()),
|
||||
"stl_cache": get_cache_map(stl_files, db),
|
||||
"stl_files": stl_files,
|
||||
"stl_cache": stl_cache,
|
||||
"materials": available_materials() or MATERIALS,
|
||||
"colors": available_colors() or COLORS,
|
||||
"spool_map": spool_counts(),
|
||||
|
||||
Reference in New Issue
Block a user