Files
bambuddy/backend/app/models/project_bom.py
T
maziggy 929c4c8cd6 - Fix total print hours calculation in set_total_hours to include all
prints (not just completed), matching get_printer_total_hours behavior
  - Add option to keep or delete archives when deleting a printer
  - Custom maintenance types no longer auto-assign to all printers
  - Add UI to manually assign/remove custom maintenance types per printer
  - Add backend endpoints for assigning types to printers and removing items
  - Exclude static/assets from large file pre-commit check
2025-12-23 09:00:36 +01:00

43 lines
1.6 KiB
Python

from datetime import datetime
from sqlalchemy import DateTime, ForeignKey, Integer, String, Text, func
from sqlalchemy.orm import Mapped, mapped_column, relationship
from backend.app.core.database import Base
class ProjectBOMItem(Base):
"""Bill of Materials item for a project."""
__tablename__ = "project_bom_items"
id: Mapped[int] = mapped_column(primary_key=True)
project_id: Mapped[int] = mapped_column(ForeignKey("projects.id", ondelete="CASCADE"))
name: Mapped[str] = mapped_column(String(255))
quantity_needed: Mapped[int] = mapped_column(Integer, default=1)
quantity_printed: Mapped[int] = mapped_column(Integer, default=0)
# Optional link to archive that prints this part
archive_id: Mapped[int | None] = mapped_column(ForeignKey("print_archives.id", ondelete="SET NULL"), nullable=True)
# Reference to attachment filename (STL file)
stl_filename: Mapped[str | None] = mapped_column(String(255), nullable=True)
# Notes about this part
notes: Mapped[str | None] = mapped_column(Text, nullable=True)
# Sort order
sort_order: Mapped[int] = mapped_column(Integer, default=0)
# Timestamps
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())
# Relationships
project: Mapped["Project"] = relationship(back_populates="bom_items")
archive: Mapped["PrintArchive | None"] = relationship()
from backend.app.models.archive import PrintArchive # noqa: E402
from backend.app.models.project import Project # noqa: E402