Add job creation with UUID, STL upload/library, search, job log, TZ, and CLAUDE.md

- PrintJob: job_uuid (UUID4), customer, logs relationship
- JobLog model + migration 0004 (also includes job_logs table)
- POST /jobs: upload STL or select from library, auto-logs 'Job created'
- GET /jobs?q=: search by customer or filename across all statuses
- app/stl.py: STL_UPLOAD_DIR helper (from env, default /data/stl)
- docker-compose: named volume stl_files mounted at /data/stl
- .env.install: added STL_UPLOAD_DIR and TZ=Europe/Berlin
- CLAUDE.md: full project context for future sessions

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martin Hohenberg
2026-06-18 21:55:49 +02:00
parent c78f8c91cd
commit fe594e8675
10 changed files with 386 additions and 27 deletions

View File

@@ -1,4 +1,5 @@
import enum
import uuid as _uuid
from datetime import datetime
from decimal import Decimal
@@ -20,9 +21,11 @@ class PrintJob(Base):
__tablename__ = "print_jobs"
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"))
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))
file_name: Mapped[str | None] = mapped_column(String(255))
status: Mapped[JobStatus] = mapped_column(Enum(JobStatus), default=JobStatus.queued)
queue_position: Mapped[int | None] = mapped_column(Integer)
@@ -39,3 +42,6 @@ class PrintJob(Base):
printer: Mapped["Printer"] = relationship(back_populates="jobs")
filament: Mapped["Filament | None"] = relationship(back_populates="jobs")
logs: Mapped[list["JobLog"]] = relationship(
back_populates="job", order_by="JobLog.created_at.desc()"
)