Add user creation and update functionality; refactor user template and helpers
This commit is contained in:
parent
f4369348c5
commit
26e55b9a3e
6 changed files with 134 additions and 24 deletions
|
@ -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")
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue