Skip to content

Commit

Permalink
Fix SA2.0 usage in webapps.base.controller (2)
Browse files Browse the repository at this point in the history
Add forms manager module for FormDefinition/FormDefintionCurrent data access functions.
  • Loading branch information
jdavcs committed Oct 25, 2023
1 parent 8cc5f75 commit a4feba5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
21 changes: 21 additions & 0 deletions lib/galaxy/managers/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from sqlalchemy import select

from galaxy.model import (
FormDefinition,
FormDefinitionCurrent,
)


def get_form_definitions(session):
stmt = select(FormDefinition)
return session.scalars(stmt)


def get_form_definitions_current(session):
stmt = select(FormDefinitionCurrent)
return session.scalars(stmt)


def get_filtered_form_definitions_current(session, filter):
stmt = select(FormDefinitionCurrent).filter_by(**filter)
return session.scalars(stmt)
6 changes: 3 additions & 3 deletions lib/galaxy/webapps/base/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1238,11 +1238,11 @@ def get_all_forms(self, trans, all_versions=False, filter=None, form_type="All")
of all the forms from the form_definition table.
"""
if all_versions:
return trans.sa_session.query(trans.app.model.FormDefinition)
return get_form_definitions(trans.sa_session)
if filter:
fdc_list = trans.sa_session.query(trans.app.model.FormDefinitionCurrent).filter_by(**filter)
fdc_list = get_filtered_form_definitions_current(trans.sa_session, filter)
else:
fdc_list = trans.sa_session.query(trans.app.model.FormDefinitionCurrent)
fdc_list = get_form_definitions_current(trans.sa_session)
if form_type == "All":
return [fdc.latest_form for fdc in fdc_list]
else:
Expand Down

0 comments on commit a4feba5

Please sign in to comment.