Make printer optional on job creation — assigned when job starts
Migration 0005 makes print_jobs.printer_id nullable. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -22,7 +22,7 @@ class PrintJob(Base):
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
job_uuid: Mapped[str | None] = mapped_column(String(36), unique=True, default=lambda: str(_uuid.uuid4()))
|
||||
printer_id: Mapped[int] = mapped_column(ForeignKey("printers.id"))
|
||||
printer_id: Mapped[int | None] = mapped_column(ForeignKey("printers.id"))
|
||||
filament_id: Mapped[int | None] = mapped_column(ForeignKey("filaments.id"))
|
||||
name: Mapped[str] = mapped_column(String(200))
|
||||
customer: Mapped[str | None] = mapped_column(String(200))
|
||||
|
||||
@@ -141,7 +141,7 @@ def jobs_page(request: Request, q: str = "", db: Session = Depends(get_db)):
|
||||
|
||||
@router.post("/jobs")
|
||||
async def create_job(
|
||||
printer_id: int = Form(...),
|
||||
printer_id: str = Form(""),
|
||||
customer: str = Form(""),
|
||||
filament_id: str = Form(""),
|
||||
notes: str = Form(""),
|
||||
@@ -160,7 +160,7 @@ async def create_job(
|
||||
job_uuid=str(_uuid.uuid4()),
|
||||
name=Path(filename).stem if filename else (customer.strip() or "Unnamed"),
|
||||
file_name=filename,
|
||||
printer_id=printer_id,
|
||||
printer_id=int(printer_id) if printer_id else None,
|
||||
filament_id=int(filament_id) if filament_id else None,
|
||||
customer=customer.strip() or None,
|
||||
notes=notes.strip() or None,
|
||||
|
||||
@@ -85,9 +85,9 @@
|
||||
|
||||
<div class="row g-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label text-secondary small">Printer <span class="text-danger">*</span></label>
|
||||
<select name="printer_id" class="form-select bg-dark border-secondary text-white" required>
|
||||
<option value="">— select —</option>
|
||||
<label class="form-label text-secondary small">Printer <span class="text-secondary fw-normal">(assigned when starting)</span></label>
|
||||
<select name="printer_id" class="form-select bg-dark border-secondary text-white">
|
||||
<option value="">— unassigned —</option>
|
||||
{% for p in printers %}
|
||||
<option value="{{ p.id }}">{{ p.name }}{% if p.location %} ({{ p.location }}){% endif %}</option>
|
||||
{% endfor %}
|
||||
|
||||
Reference in New Issue
Block a user