From cde5fdd9abc84f0691aef39b496d251ba5b0e81e Mon Sep 17 00:00:00 2001 From: John Davis Date: Wed, 20 Sep 2023 18:10:56 -0400 Subject: [PATCH] Drop old repositories, group repo functions in one module --- lib/galaxy/managers/users.py | 2 +- lib/galaxy/tool_shed/util/repository_util.py | 5 ++--- lib/galaxy/webapps/galaxy/controllers/history.py | 5 ++--- lib/galaxy/webapps/galaxy/controllers/user.py | 2 +- lib/tool_shed/test/base/test_db_util.py | 2 +- lib/tool_shed/webapp/controllers/repository.py | 2 +- test/integration/test_user_preferences.py | 2 +- test/integration/test_vault_extra_prefs.py | 2 +- test/integration/test_vault_file_source.py | 2 +- 9 files changed, 11 insertions(+), 13 deletions(-) diff --git a/lib/galaxy/managers/users.py b/lib/galaxy/managers/users.py index 8a3ce9cba072..86879131d12d 100644 --- a/lib/galaxy/managers/users.py +++ b/lib/galaxy/managers/users.py @@ -37,7 +37,7 @@ ) from galaxy.model import UserQuotaUsage from galaxy.model.base import transaction -from galaxy.model.repositories.user import ( +from galaxy.model.repositories import ( get_user_by_email, get_user_by_username, ) diff --git a/lib/galaxy/tool_shed/util/repository_util.py b/lib/galaxy/tool_shed/util/repository_util.py index 4d31a47f5c06..674048937359 100644 --- a/lib/galaxy/tool_shed/util/repository_util.py +++ b/lib/galaxy/tool_shed/util/repository_util.py @@ -26,7 +26,6 @@ web, ) from galaxy.model.base import transaction -from galaxy.model.repositories.tool_shed_repository import ToolShedRepositoryRepository as tsr_repo from galaxy.model.scoped_session import install_model_scoped_session from galaxy.model.tool_shed_install import ToolShedRepository from galaxy.tool_shed.util import basic_util @@ -70,7 +69,7 @@ def check_for_updates( message += "Unable to retrieve status from the tool shed for the following repositories:\n" message += ", ".join(repository_names_not_updated) else: - repository = tsr_repo(install_model_context).get(repository_id) + repository = install_model_context.get(ToolShedRepository, repository_id) ok, updated = _check_or_update_tool_shed_status_for_installed_repository( tool_shed_registry, install_model_context, repository ) @@ -633,7 +632,7 @@ def get_tool_shed_from_clone_url(repository_clone_url): def get_tool_shed_repository_by_id(app, repository_id) -> ToolShedRepository: """Return a tool shed repository database record defined by the id.""" # This method is used only in Galaxy, not the tool shed. - return tsr_repo(app.install_model.context).get(app.security.decode_id(repository_id)) + return app.install_model.context.get(ToolShedRepository, app.security.decode_id(repository_id)) def get_tool_shed_status_for(tool_shed_registry: Registry, repository: ToolShedRepository): diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index 2bc59b1aee45..2dd00d2d487d 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -16,12 +16,12 @@ ) from galaxy.managers import histories from galaxy.managers.sharable import SlugBuilder +from galaxy.model import Role from galaxy.model.base import transaction from galaxy.model.item_attrs import ( UsesAnnotations, UsesItemRatings, ) -from galaxy.model.repositories.role import RoleRepository from galaxy.structured_app import StructuredApp from galaxy.util import ( listify, @@ -576,10 +576,9 @@ def permissions(self, trans, payload=None, **kwd): else: self.history_manager.error_unless_mutable(history) permissions = {} - _role_repo = RoleRepository(trans.sa_session) for action_key, action in trans.app.model.Dataset.permitted_actions.items(): in_roles = payload.get(action_key) or [] - in_roles = [_role_repo.get(trans.security.decode_id(x)) for x in in_roles] + in_roles = [trans.sa_session.get(Role, trans.security.decode_id(x)) for x in in_roles] permissions[trans.app.security_agent.get_action(action.action)] = in_roles trans.app.security_agent.history_set_default_permissions(history, permissions) return {"message": "Default history '%s' dataset permissions have been changed." % history.name} diff --git a/lib/galaxy/webapps/galaxy/controllers/user.py b/lib/galaxy/webapps/galaxy/controllers/user.py index 31a43eb3c31e..275510cff2ee 100644 --- a/lib/galaxy/webapps/galaxy/controllers/user.py +++ b/lib/galaxy/webapps/galaxy/controllers/user.py @@ -18,7 +18,7 @@ ) from galaxy.exceptions import Conflict from galaxy.managers import users -from galaxy.model.repositories.user import get_user_by_email +from galaxy.model.repositories import get_user_by_email from galaxy.security.validate_user_input import ( validate_email, validate_publicname, diff --git a/lib/tool_shed/test/base/test_db_util.py b/lib/tool_shed/test/base/test_db_util.py index e7e4c88415f9..1f1655ec73a3 100644 --- a/lib/tool_shed/test/base/test_db_util.py +++ b/lib/tool_shed/test/base/test_db_util.py @@ -10,7 +10,7 @@ import galaxy.model import galaxy.model.tool_shed_install import tool_shed.webapp.model as model -from galaxy.model.repositories.user import get_user_by_username +from galaxy.model.repositories import get_user_by_username log = logging.getLogger("test.tool_shed.test_db_util") diff --git a/lib/tool_shed/webapp/controllers/repository.py b/lib/tool_shed/webapp/controllers/repository.py index 747162130692..0f0b9548e7f7 100644 --- a/lib/tool_shed/webapp/controllers/repository.py +++ b/lib/tool_shed/webapp/controllers/repository.py @@ -25,7 +25,7 @@ web, ) from galaxy.model.base import transaction -from galaxy.model.repositories.user import get_user_by_username +from galaxy.model.repositories import get_user_by_username from galaxy.tool_shed.util import dependency_display from galaxy.tools.repositories import ValidationContext from galaxy.web.form_builder import ( diff --git a/test/integration/test_user_preferences.py b/test/integration/test_user_preferences.py index e6f758a3600e..f7a365393535 100644 --- a/test/integration/test_user_preferences.py +++ b/test/integration/test_user_preferences.py @@ -8,7 +8,7 @@ put, ) -from galaxy.model.repositories.user import get_user_by_email +from galaxy.model.repositories import get_user_by_email from galaxy_test.driver import integration_util TEST_USER_EMAIL = "test_user_preferences@bx.psu.edu" diff --git a/test/integration/test_vault_extra_prefs.py b/test/integration/test_vault_extra_prefs.py index b1ad24643766..40b82c0ae04b 100644 --- a/test/integration/test_vault_extra_prefs.py +++ b/test/integration/test_vault_extra_prefs.py @@ -10,7 +10,7 @@ put, ) -from galaxy.model.repositories.user import get_user_by_email +from galaxy.model.repositories import get_user_by_email from galaxy_test.driver import integration_util TEST_USER_EMAIL = "vault_test_user@bx.psu.edu" diff --git a/test/integration/test_vault_file_source.py b/test/integration/test_vault_file_source.py index af58c069de4a..a3cf477721a5 100644 --- a/test/integration/test_vault_file_source.py +++ b/test/integration/test_vault_file_source.py @@ -1,7 +1,7 @@ import os import tempfile -from galaxy.model.repositories.user import get_user_by_email +from galaxy.model.repositories import get_user_by_email from galaxy.security.vault import UserVaultWrapper from galaxy_test.base import api_asserts from galaxy_test.base.populators import DatasetPopulator