Skip to content

Commit

Permalink
Deprecated: SignatureRoles table in sqlalchemy factory (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
signebedi committed Aug 3, 2024
1 parent 7f77234 commit d929f87
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 22 deletions.
32 changes: 16 additions & 16 deletions libreforms_fastapi/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ def validation_exception_handler(request: Request, exc: RequestValidationError):
PasswordReuse = models['PasswordReuse']
Group = models['Group']
TransactionLog = models['TransactionLog']
SignatureRoles = models['SignatureRoles']
# SignatureRoles = models['SignatureRoles']
Signing = models['Signing']

# Adding user relationship models below, see
Expand Down Expand Up @@ -604,21 +604,21 @@ def validation_exception_handler(request: Request, exc: RequestValidationError):
logger.info("Default group already exists")

# Check if a signature role with id 1 exists
_default_signature_role = session.query(SignatureRoles).get(1)

if not _default_signature_role:
# If not, create and add the new signature for the example_form
_default_signature_role = SignatureRoles(
id=1,
role_name="default signature role",
role_method="signature",
form_name="example_form"
)
session.add(_default_signature_role)
session.commit()
logger.info("Default signature role created")
else:
logger.info("Default signature role already exists")
# _default_signature_role = session.query(SignatureRoles).get(1)

# if not _default_signature_role:
# # If not, create and add the new signature for the example_form
# _default_signature_role = SignatureRoles(
# id=1,
# role_name="default signature role",
# role_method="signature",
# form_name="example_form"
# )
# session.add(_default_signature_role)
# session.commit()
# logger.info("Default signature role created")
# else:
# logger.info("Default signature role already exists")



Expand Down
6 changes: 3 additions & 3 deletions libreforms_fastapi/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def cli_useradd(username, password, email, opt_out, site_admin, environment):
User = models['User']
Group = models['Group']
TransactionLog = models['TransactionLog']
SignatureRoles = models['SignatureRoles']
# SignatureRoles = models['SignatureRoles']
Signing = models['Signing']

Base.metadata.create_all(bind=engine)
Expand Down Expand Up @@ -548,7 +548,7 @@ def cli_usermod(username, password, new_email, opt_out, active, site_admin, head
User = models['User']
Group = models['Group']
TransactionLog = models['TransactionLog']
SignatureRoles = models['SignatureRoles']
# SignatureRoles = models['SignatureRoles']
Signing = models['Signing']

Base.metadata.create_all(bind=engine)
Expand Down Expand Up @@ -658,7 +658,7 @@ def cli_id(username, environment):
User = models['User']
Group = models['Group']
TransactionLog = models['TransactionLog']
SignatureRoles = models['SignatureRoles']
# SignatureRoles = models['SignatureRoles']
Signing = models['Signing']

Base.metadata.create_all(bind=engine)
Expand Down
5 changes: 3 additions & 2 deletions libreforms_fastapi/utils/sqlalchemy_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,8 @@ def to_dict(self):



# Allow custom approval chains to be defined here
# Allow custom approval chains to be defined here. Deprecated in favor of config-based
# approach, see https://github.com/signebedi/libreforms-fastapi/issues/62.
class SignatureRoles(Base):
__tablename__ = 'signature_roles'
id = Column(Integer, primary_key=True)
Expand Down Expand Up @@ -477,7 +478,7 @@ def to_dict(self):
"PasswordReuse": PasswordReuse,
"Group": Group,
"TransactionLog": TransactionLog,
"SignatureRoles": SignatureRoles,
# "SignatureRoles": SignatureRoles,
"Signing": Signing,
"RelationshipType": RelationshipType,
"UserRelationship": UserRelationship,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setup_environment():
User,
Group,
TransactionLog,
SignatureRoles,
# SignatureRoles,
Signing,
signatures,
engine,
Expand Down

0 comments on commit d929f87

Please sign in to comment.