Add title field to User model and update related views for user management
This commit is contained in:
parent
fd148eb484
commit
f89b825ef0
6 changed files with 94 additions and 14 deletions
|
@ -19,6 +19,7 @@ class User(db.Model, ImageAttachable):
|
|||
active: Mapped[Optional[bool]] = mapped_column(Boolean, server_default=text('((0))'))
|
||||
last_name: Mapped[Optional[str]] = mapped_column(Unicode(255), nullable=True)
|
||||
first_name: Mapped[Optional[str]] = mapped_column(Unicode(255), nullable=True)
|
||||
title: Mapped[Optional[str]] = mapped_column(Unicode(255), nullable=True, default=None)
|
||||
location_id: Mapped[Optional[int]] = mapped_column(ForeignKey("rooms.id"), nullable=True, index=True)
|
||||
supervisor_id: Mapped[Optional[int]] = mapped_column(Integer, ForeignKey("users.id"), nullable=True, index=True)
|
||||
image_id: Mapped[Optional[int]] = mapped_column(ForeignKey('images.id', ondelete='SET NULL'), nullable=True, index=True)
|
||||
|
@ -35,10 +36,12 @@ class User(db.Model, ImageAttachable):
|
|||
return f"{self.first_name or ''} {self.last_name or ''}".strip()
|
||||
|
||||
def __init__(self, first_name: Optional[str] = None, last_name: Optional[str] = None,
|
||||
location_id: Optional[int] = None, supervisor_id: Optional[int] = None,
|
||||
staff: Optional[bool] = False, active: Optional[bool] = False):
|
||||
title: Optional[str] = None,location_id: Optional[int] = None,
|
||||
supervisor_id: Optional[int] = None, staff: Optional[bool] = False,
|
||||
active: Optional[bool] = False):
|
||||
self.first_name = first_name
|
||||
self.last_name = last_name
|
||||
self.title = title
|
||||
self.location_id = location_id
|
||||
self.supervisor_id = supervisor_id
|
||||
self.staff = staff
|
||||
|
@ -53,6 +56,7 @@ class User(db.Model, ImageAttachable):
|
|||
'id': self.id,
|
||||
'first_name': self.first_name,
|
||||
'last_name': self.last_name,
|
||||
'title': self.title,
|
||||
'location_id': self.location_id,
|
||||
'supervisor_id': self.supervisor_id,
|
||||
'staff': self.staff,
|
||||
|
@ -66,6 +70,7 @@ class User(db.Model, ImageAttachable):
|
|||
active=bool(data.get("active", False)),
|
||||
last_name=data.get("last_name"),
|
||||
first_name=data.get("first_name"),
|
||||
title=data.get("title"),
|
||||
location_id=data.get("location_id"),
|
||||
supervisor_id=data.get("supervisor_id")
|
||||
)
|
Loading…
Add table
Add a link
Reference in a new issue