Add inventory item creation and update endpoints; enhance inventory template with form handling

This commit is contained in:
Yaro Kasear 2025-07-07 09:40:27 -05:00
parent a1d3f58081
commit dc394dd992
4 changed files with 159 additions and 2 deletions

View file

@ -106,3 +106,21 @@ class Inventory(db.Model):
'barcode': self.barcode,
'shared': self.shared
}
@classmethod
def from_dict(cls, data: dict[str, Any]) -> "Inventory":
return cls(
timestamp=datetime.datetime.fromisoformat(data.get("timestamp")) if data.get("timestamp") else datetime.datetime.now(),
condition=data.get("condition", "Unverified"),
needed=data.get("needed", ""),
type_id=data["type_id"],
inventory_name=data.get("inventory_name"),
serial=data.get("serial"),
model=data.get("model"),
notes=data.get("notes"),
owner_id=data.get("owner_id"),
brand_id=data.get("brand_id"),
location_id=data.get("location_id"),
barcode=data.get("barcode"),
shared=bool(data.get("shared", False))
)