Skip to content

Commit

Permalink
Added: groups field to user data model (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Mar 23, 2024
1 parent 4182733 commit 53d4979
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libreforms_fastapi/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions libreforms_fastapi/utils/sqlalchemy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand Down

0 comments on commit 53d4979

Please sign in to comment.