Added filament color code field
This commit is contained in:
@@ -73,6 +73,12 @@ class FilamentParameters(BaseModel):
|
||||
description="Overridden bed temperature, in °C.",
|
||||
example=60,
|
||||
)
|
||||
color_hex: Optional[str] = Field(
|
||||
min_length=6,
|
||||
max_length=6,
|
||||
description="Hexadecimal color code of the filament, e.g. FF0000 for red. (no leading #)",
|
||||
example="FF0000",
|
||||
)
|
||||
|
||||
|
||||
class FilamentUpdateParameters(FilamentParameters):
|
||||
@@ -164,6 +170,7 @@ async def create(
|
||||
comment=body.comment,
|
||||
settings_extruder_temp=body.settings_extruder_temp,
|
||||
settings_bed_temp=body.settings_bed_temp,
|
||||
color_hex=body.color_hex,
|
||||
)
|
||||
|
||||
return Filament.from_db(db_item)
|
||||
|
||||
@@ -79,6 +79,12 @@ class Filament(BaseModel):
|
||||
description="Overridden bed temperature, in °C.",
|
||||
example=60,
|
||||
)
|
||||
color_hex: Optional[str] = Field(
|
||||
min_length=6,
|
||||
max_length=6,
|
||||
description="Hexadecimal color code of the filament, e.g. FF0000 for red. (no leading #)",
|
||||
example="FF0000",
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def from_db(item: models.Filament) -> "Filament":
|
||||
@@ -98,6 +104,7 @@ class Filament(BaseModel):
|
||||
comment=item.comment,
|
||||
settings_extruder_temp=item.settings_extruder_temp,
|
||||
settings_bed_temp=item.settings_bed_temp,
|
||||
color_hex=item.color_hex,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ async def create(
|
||||
comment: Optional[str] = None,
|
||||
settings_extruder_temp: Optional[int] = None,
|
||||
settings_bed_temp: Optional[int] = None,
|
||||
color_hex: Optional[str] = None,
|
||||
) -> models.Filament:
|
||||
"""Add a new filament to the database."""
|
||||
vendor_item: models.Vendor | None = None
|
||||
@@ -45,6 +46,7 @@ async def create(
|
||||
comment=comment,
|
||||
settings_extruder_temp=settings_extruder_temp,
|
||||
settings_bed_temp=settings_bed_temp,
|
||||
color_hex=color_hex,
|
||||
)
|
||||
db.add(db_item)
|
||||
await db.flush()
|
||||
|
||||
@@ -41,6 +41,7 @@ class Filament(Base):
|
||||
comment: Mapped[Optional[str]] = mapped_column(String(1024))
|
||||
settings_extruder_temp: Mapped[Optional[int]] = mapped_column(comment="Overridden extruder temperature.")
|
||||
settings_bed_temp: Mapped[Optional[int]] = mapped_column(comment="Overridden bed temperature.")
|
||||
color_hex: Mapped[Optional[str]] = mapped_column(String(6))
|
||||
|
||||
|
||||
class Spool(Base):
|
||||
|
||||
Reference in New Issue
Block a user