From 53d49794d480b8eebec62f4ac6cb749f10135995 Mon Sep 17 00:00:00 2001 From: signebedi Date: Sat, 23 Mar 2024 17:26:22 -0500 Subject: [PATCH] Added: `groups` field to user data model (#22) --- libreforms_fastapi/app/__init__.py | 6 ++++++ libreforms_fastapi/utils/sqlalchemy_models.py | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/libreforms_fastapi/app/__init__.py b/libreforms_fastapi/app/__init__.py index 3c6d587..e2492d1 100644 --- a/libreforms_fastapi/app/__init__.py +++ b/libreforms_fastapi/app/__init__.py @@ -685,3 +685,9 @@ async def api_auth_create(user_request: CreateUserRequest, background_tasks: Bac # Database Config # Site Reload + +# Edit form config + +# Manage groups + +# Manage approval chains \ No newline at end of file diff --git a/libreforms_fastapi/utils/sqlalchemy_models.py b/libreforms_fastapi/utils/sqlalchemy_models.py index 774fd4f..f661721 100644 --- a/libreforms_fastapi/utils/sqlalchemy_models.py +++ b/libreforms_fastapi/utils/sqlalchemy_models.py @@ -32,6 +32,7 @@ class User(Base): email = Column(String(1000)) password = Column(String(1000)) username = Column(String(1000), unique=True) + groups = Column(JSON, default=list) active = Column(Boolean) created_date = Column(DateTime, nullable=False, default=tz_aware_datetime) last_login = Column(DateTime, nullable=True, default=tz_aware_datetime) @@ -47,6 +48,9 @@ class User(Base): transaction_log = relationship("TransactionLog", order_by="TransactionLog.id", back_populates="user") + def __repr__(self) -> str: + return f"User(id={self.id!r}, name={self.username!r}, site_admin={'Yes' if self.site_admin else 'No'}, " \ + f"active={'Yes' if self.active else 'No'}, groups={self.groups})" # Many to one relationship with User table class TransactionLog(Base):