Add user creation and update functionality; refactor user template and helpers

This commit is contained in:
Yaro Kasear 2025-07-07 15:36:15 -05:00
parent f4369348c5
commit 26e55b9a3e
6 changed files with 134 additions and 24 deletions

View file

@ -1,4 +1,4 @@
from typing import List, Optional, TYPE_CHECKING
from typing import Any, List, Optional, TYPE_CHECKING
if TYPE_CHECKING:
from .inventory import Inventory
from .rooms import Room
@ -55,3 +55,14 @@ class User(db.Model):
'staff': self.staff,
'active': self.active
}
@classmethod
def from_dict(cls, data: dict[str, Any]) -> "User":
return cls(
staff=bool(data.get("staff", False)),
active=bool(data.get("active", False)),
last_name=data.get("last_name"),
first_name=data.get("first_name"),
location_id=data.get("location_id"),
supervisor_id=data.get("supervisor_id")
)