Add inventory item creation and update endpoints; enhance inventory template with form handling
This commit is contained in:
parent
a1d3f58081
commit
dc394dd992
4 changed files with 159 additions and 2 deletions
|
@ -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))
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue