Add printer types with bed volume + add-printer UI
- PrinterType model: name, bed_x_mm/y/z, linked to Printer via type_id - Migration 0002: creates printer_types, adds type_id to printers, drops model - /printer-types page: table + Add Type modal form - /printers page: Add Printer modal with type dropdown (disabled if no types) - API: GET/POST/DELETE /api/printer-types Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@ from app.models.filament import Filament
|
||||
from app.models.pricing import PricingConfig
|
||||
from app.models.print_job import PrintJob
|
||||
from app.models.printer import Printer
|
||||
from app.models.printer_type import PrinterType
|
||||
from app.models.todo import Todo
|
||||
|
||||
__all__ = ["Base", "Printer", "Filament", "PrintJob", "Todo", "PricingConfig"]
|
||||
__all__ = ["Base", "Printer", "PrinterType", "Filament", "PrintJob", "Todo", "PricingConfig"]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import enum
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, Enum, String, func
|
||||
from sqlalchemy import DateTime, Enum, ForeignKey, String, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base
|
||||
@@ -19,8 +19,8 @@ class Printer(Base):
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(100))
|
||||
model: Mapped[str | None] = mapped_column(String(100))
|
||||
location: Mapped[str | None] = mapped_column(String(100))
|
||||
type_id: Mapped[int | None] = mapped_column(ForeignKey("printer_types.id"))
|
||||
status: Mapped[PrinterStatus] = mapped_column(
|
||||
Enum(PrinterStatus), default=PrinterStatus.offline
|
||||
)
|
||||
@@ -29,5 +29,6 @@ class Printer(Base):
|
||||
DateTime, server_default=func.now(), onupdate=func.now()
|
||||
)
|
||||
|
||||
printer_type: Mapped["PrinterType | None"] = relationship(back_populates="printers")
|
||||
jobs: Mapped[list["PrintJob"]] = relationship(back_populates="printer")
|
||||
todos: Mapped[list["Todo"]] = relationship(back_populates="printer")
|
||||
|
||||
19
app/models/printer_type.py
Normal file
19
app/models/printer_type.py
Normal file
@@ -0,0 +1,19 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, Integer, String, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class PrinterType(Base):
|
||||
__tablename__ = "printer_types"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
name: Mapped[str] = mapped_column(String(100), unique=True)
|
||||
bed_x_mm: Mapped[int] = mapped_column(Integer)
|
||||
bed_y_mm: Mapped[int] = mapped_column(Integer)
|
||||
bed_z_mm: Mapped[int] = mapped_column(Integer)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||
|
||||
printers: Mapped[list["Printer"]] = relationship(back_populates="printer_type")
|
||||
Reference in New Issue
Block a user