Replace combined filament dropdown with separate material + color dropdowns
- app/constants.py: MATERIALS and COLORS standard value lists
- Migration 0008: job_material + job_color columns on print_jobs
- Job creation (both /jobs and /brackets/{id}/jobs) stores these independently
of the filament inventory
- All job tables updated to display job_material · job_color
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ from app.models.printer_log import PrinterLog
|
||||
from app.models.printer_type import PrinterType
|
||||
from app.models.pricing import PricingConfig
|
||||
from app.models.todo import Todo
|
||||
from app.constants import COLORS, MATERIALS
|
||||
from app.stl import get_stl_dir, list_stl_files
|
||||
from app.stl_analysis import analyse, get_cache_map
|
||||
|
||||
@@ -140,6 +141,8 @@ def jobs_page(request: Request, q: str = "", db: Session = Depends(get_db)):
|
||||
"brackets": db.query(JobBracket).order_by(JobBracket.name).all(),
|
||||
"stl_files": (stl_files := list_stl_files()),
|
||||
"stl_cache": get_cache_map(stl_files, db),
|
||||
"materials": MATERIALS,
|
||||
"colors": COLORS,
|
||||
})
|
||||
|
||||
|
||||
@@ -147,7 +150,8 @@ def jobs_page(request: Request, q: str = "", db: Session = Depends(get_db)):
|
||||
async def create_job(
|
||||
printer_id: str = Form(""),
|
||||
customer: str = Form(""),
|
||||
filament_id: str = Form(""),
|
||||
job_material: str = Form(""),
|
||||
job_color: str = Form(""),
|
||||
bracket_id: str = Form(""),
|
||||
amount: int = Form(1),
|
||||
notes: str = Form(""),
|
||||
@@ -184,9 +188,10 @@ async def create_job(
|
||||
name=job_name,
|
||||
file_name=filename,
|
||||
printer_id=int(printer_id) if printer_id else None,
|
||||
filament_id=int(filament_id) if filament_id else None,
|
||||
bracket_id=effective_bracket_id,
|
||||
customer=customer_str,
|
||||
job_material=job_material or None,
|
||||
job_color=job_color or None,
|
||||
notes=notes.strip() or None,
|
||||
)
|
||||
db.add(job)
|
||||
@@ -236,6 +241,8 @@ def bracket_detail(bracket_id: int, request: Request, db: Session = Depends(get_
|
||||
"filaments": db.query(Filament).order_by(Filament.material, Filament.color).all(),
|
||||
"stl_files": (stl_files := list_stl_files()),
|
||||
"stl_cache": get_cache_map(stl_files, db),
|
||||
"materials": MATERIALS,
|
||||
"colors": COLORS,
|
||||
})
|
||||
|
||||
|
||||
@@ -243,7 +250,8 @@ def bracket_detail(bracket_id: int, request: Request, db: Session = Depends(get_
|
||||
async def add_jobs_to_bracket(
|
||||
bracket_id: int,
|
||||
quantity: int = Form(1),
|
||||
filament_id: str = Form(""),
|
||||
job_material: str = Form(""),
|
||||
job_color: str = Form(""),
|
||||
notes: str = Form(""),
|
||||
stl_file: UploadFile = File(None),
|
||||
stl_select: str = Form(""),
|
||||
@@ -263,7 +271,8 @@ async def add_jobs_to_bracket(
|
||||
name=Path(filename).stem if filename else "Unnamed",
|
||||
file_name=filename,
|
||||
bracket_id=bracket_id,
|
||||
filament_id=int(filament_id) if filament_id else None,
|
||||
job_material=job_material or None,
|
||||
job_color=job_color or None,
|
||||
notes=notes.strip() or None,
|
||||
)
|
||||
db.add(job)
|
||||
|
||||
Reference in New Issue
Block a user