Skip to content

Commit

Permalink
Added: placeholder groups table (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Mar 23, 2024
1 parent 35d4a69 commit b79aa11
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion libreforms_fastapi/utils/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def get_form_names(config_path=config.FORM_CONFIG_PATH):
return form_config.keys()

def get_form_config(form_name, config_path=config.FORM_CONFIG_PATH):
"""Yields a single config dict for the form name passed"""
"""Yields a single config dict for the form name passed, following a factory pattern approach"""
# Try to open config_path and if not existent or empty, use example config
form_config = example_form_config # Default to example_form_config

Expand Down
12 changes: 11 additions & 1 deletion libreforms_fastapi/utils/sqlalchemy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,18 @@ class TransactionLog(Base):
# date = Column(Date, nullable=False, default=lambda: datetime.utcnow().date())
endpoint = Column(String(1000))
remote_addr = Column(String(50), nullable=True)
query_params = Column(String(2000), nullable=True) # Can we find a way to make this a JSON string or similar format?
query_params = Column(String(2000), nullable=True) # Can we find a way to make this a JSON string or similar format?

user = relationship("User", back_populates="transaction_log")

# Allow admins to define custom groups, see
# https://github.com/signebedi/libreforms-fastapi/issues/22
class Group(Base):
__tablename__ = 'group'
id = Column(Integer, primary_key=True)
name = Column(String(1000), unique=True)
permissions = Column(JSON)


# Create a custom Signing class from sqlalchemy_signing
Signing = create_signing_class(Base, tz_aware_datetime)

0 comments on commit b79aa11

Please sign in to comment.