|
|
|
|
@@ -155,13 +155,14 @@ def jobs_page(request: Request, q: str = "", bracket_id: str = "", show_all: str
|
|
|
|
|
or_(~PrintJob.status.in_(finished), PrintJob.created_at >= cutoff)
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Sort: printing → queued → rest, then priority, then oldest first
|
|
|
|
|
# Sort: printing → queued → rest, then priority flag, then internal last, then oldest first
|
|
|
|
|
status_order = case(
|
|
|
|
|
(PrintJob.status == JobStatus.printing, 0),
|
|
|
|
|
(PrintJob.status == JobStatus.queued, 1),
|
|
|
|
|
else_=2,
|
|
|
|
|
)
|
|
|
|
|
jobs = query.order_by(status_order, PrintJob.priority.desc(), PrintJob.created_at.asc()).all()
|
|
|
|
|
internal_last = case((PrintJob.customer == "internal", 1), else_=0)
|
|
|
|
|
jobs = query.order_by(status_order, PrintJob.priority.desc(), internal_last, PrintJob.created_at.asc()).all()
|
|
|
|
|
|
|
|
|
|
stl_files = list_stl_files()
|
|
|
|
|
stl_cache = get_cache_map(stl_files, db)
|
|
|
|
|
@@ -221,7 +222,7 @@ async def create_job(
|
|
|
|
|
filename = stl_select
|
|
|
|
|
|
|
|
|
|
amount = max(1, amount)
|
|
|
|
|
customer_str = customer.strip() or None
|
|
|
|
|
customer_str = customer.strip() or "internal"
|
|
|
|
|
job_name = Path(filename).stem if filename else (customer_str or "Unnamed")
|
|
|
|
|
|
|
|
|
|
# Resolve bracket — auto-create one when printing multiple copies
|
|
|
|
|
@@ -320,7 +321,7 @@ def edit_job(
|
|
|
|
|
job = db.query(PrintJob).filter(PrintJob.id == job_id).first()
|
|
|
|
|
if not job:
|
|
|
|
|
raise HTTPException(status_code=404, detail="Job not found")
|
|
|
|
|
job.customer = customer.strip() or None
|
|
|
|
|
job.customer = customer.strip() or "internal"
|
|
|
|
|
job.job_material = job_material or None
|
|
|
|
|
job.job_color = job_color or None
|
|
|
|
|
job.priority = bool(priority)
|
|
|
|
|
|