Added registered fields to all objects
This commit is contained in:
@@ -14,6 +14,7 @@ class Message(BaseModel):
|
|||||||
|
|
||||||
class Vendor(BaseModel):
|
class Vendor(BaseModel):
|
||||||
id: int = Field(description="Unique internal ID of this vendor.")
|
id: int = Field(description="Unique internal ID of this vendor.")
|
||||||
|
registered: datetime = Field(description="When the vendor was registered in the database.")
|
||||||
name: str = Field(max_length=64, description="Vendor name.", example="Polymaker")
|
name: str = Field(max_length=64, description="Vendor name.", example="Polymaker")
|
||||||
comment: Optional[str] = Field(max_length=1024, description="Free text comment about this vendor.", example="")
|
comment: Optional[str] = Field(max_length=1024, description="Free text comment about this vendor.", example="")
|
||||||
|
|
||||||
@@ -22,6 +23,7 @@ class Vendor(BaseModel):
|
|||||||
"""Create a new Pydantic vendor object from a database vendor object."""
|
"""Create a new Pydantic vendor object from a database vendor object."""
|
||||||
return Vendor(
|
return Vendor(
|
||||||
id=item.id,
|
id=item.id,
|
||||||
|
registered=item.registered,
|
||||||
name=item.name,
|
name=item.name,
|
||||||
comment=item.comment,
|
comment=item.comment,
|
||||||
)
|
)
|
||||||
@@ -29,6 +31,7 @@ class Vendor(BaseModel):
|
|||||||
|
|
||||||
class Filament(BaseModel):
|
class Filament(BaseModel):
|
||||||
id: int = Field(description="Unique internal ID of this filament type.")
|
id: int = Field(description="Unique internal ID of this filament type.")
|
||||||
|
registered: datetime = Field(description="When the filament was registered in the database.")
|
||||||
name: Optional[str] = Field(
|
name: Optional[str] = Field(
|
||||||
max_length=64,
|
max_length=64,
|
||||||
description=(
|
description=(
|
||||||
@@ -72,6 +75,7 @@ class Filament(BaseModel):
|
|||||||
"""Create a new Pydantic filament object from a database filament object."""
|
"""Create a new Pydantic filament object from a database filament object."""
|
||||||
return Filament(
|
return Filament(
|
||||||
id=item.id,
|
id=item.id,
|
||||||
|
registered=item.registered,
|
||||||
name=item.name,
|
name=item.name,
|
||||||
vendor=Vendor.from_db(item.vendor) if item.vendor is not None else None,
|
vendor=Vendor.from_db(item.vendor) if item.vendor is not None else None,
|
||||||
material=item.material,
|
material=item.material,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ class Vendor(Base):
|
|||||||
__tablename__ = "vendor"
|
__tablename__ = "vendor"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||||
|
registered: Mapped[datetime] = mapped_column(default=func.now())
|
||||||
name: Mapped[str] = mapped_column(String(64))
|
name: Mapped[str] = mapped_column(String(64))
|
||||||
comment: Mapped[Optional[str]] = mapped_column(String(1024))
|
comment: Mapped[Optional[str]] = mapped_column(String(1024))
|
||||||
filaments: Mapped[list["Filament"]] = relationship(back_populates="vendor")
|
filaments: Mapped[list["Filament"]] = relationship(back_populates="vendor")
|
||||||
@@ -25,6 +26,7 @@ class Filament(Base):
|
|||||||
__tablename__ = "filament"
|
__tablename__ = "filament"
|
||||||
|
|
||||||
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
||||||
|
registered: Mapped[datetime] = mapped_column(default=func.now())
|
||||||
name: Mapped[Optional[str]] = mapped_column(String(64))
|
name: Mapped[Optional[str]] = mapped_column(String(64))
|
||||||
vendor_id: Mapped[Optional[int]] = mapped_column(ForeignKey("vendor.id"))
|
vendor_id: Mapped[Optional[int]] = mapped_column(ForeignKey("vendor.id"))
|
||||||
vendor: Mapped[Optional["Vendor"]] = relationship(back_populates="filaments")
|
vendor: Mapped[Optional["Vendor"]] = relationship(back_populates="filaments")
|
||||||
|
|||||||
Reference in New Issue
Block a user