Filament removal:
- Deleted app/models/filament.py, routers/filaments.py, templates/filaments.html
- Migration 0009: drops filaments table and filament_id FK from print_jobs
- Removed Filaments from sidebar and all internal references
FilamentDB integration (read-only):
- app/filamentdb.py: GET /reports/stock with 5-min in-memory cache
- available_materials() / available_colors() populate job form dropdowns
- Falls back to static constants if FilamentDB unreachable
- Dashboard filament count now from FilamentDB rolls_in_stock
- FILAMENTDB_URL added to .env.install; httpx added to requirements
Job detail page (/jobs/{id}):
- Two cards: Job info (customer, material, printer, bracket, timing, cost)
and File & Geometry (bounding box + volume from stl_cache)
- Log timeline with Add Entry modal
- Filename in jobs list links to detail page
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
50 lines
2.1 KiB
Python
50 lines
2.1 KiB
Python
import enum
|
|
import uuid as _uuid
|
|
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
from sqlalchemy import DateTime, Enum, ForeignKey, Integer, String, Text, func
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.models.base import Base
|
|
|
|
|
|
class JobStatus(enum.Enum):
|
|
queued = "queued"
|
|
printing = "printing"
|
|
done = "done"
|
|
failed = "failed"
|
|
cancelled = "cancelled"
|
|
|
|
|
|
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 | None] = mapped_column(ForeignKey("printers.id"))
|
|
bracket_id: Mapped[int | None] = mapped_column(ForeignKey("job_brackets.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))
|
|
job_material: Mapped[str | None] = mapped_column(String(50))
|
|
job_color: Mapped[str | None] = mapped_column(String(100))
|
|
status: Mapped[JobStatus] = mapped_column(Enum(JobStatus), default=JobStatus.queued)
|
|
queue_position: Mapped[int | None] = mapped_column(Integer)
|
|
started_at: Mapped[datetime | None] = mapped_column(DateTime)
|
|
finished_at: Mapped[datetime | None] = mapped_column(DateTime)
|
|
duration_minutes: Mapped[int | None] = mapped_column(Integer)
|
|
filament_used_g: Mapped[Decimal | None] = mapped_column(Numeric(8, 2))
|
|
cost_eur: Mapped[Decimal | None] = mapped_column(Numeric(8, 2))
|
|
notes: Mapped[str | None] = mapped_column(Text)
|
|
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, server_default=func.now(), onupdate=func.now()
|
|
)
|
|
|
|
printer: Mapped["Printer"] = relationship(back_populates="jobs")
|
|
bracket: Mapped["JobBracket | None"] = relationship(back_populates="jobs")
|
|
logs: Mapped[list["JobLog"]] = relationship(
|
|
back_populates="job", order_by="JobLog.created_at.desc()"
|
|
)
|