Skip to content

Commit

Permalink
Move get_user_by_username into repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
jdavcs committed Aug 17, 2023
1 parent 844afed commit 0a795a6
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 14 deletions.
13 changes: 0 additions & 13 deletions lib/galaxy/managers/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
and_,
exc,
func,
select,
true,
)
from sqlalchemy.orm.exc import NoResultFound
Expand Down Expand Up @@ -838,15 +837,3 @@ def _add_parsers(self):
)

self.fn_filter_parsers.update({})


def get_user_by_username(session, user_class, username):
"""
Get a user from the database by username.
(We pass the session and the user_class to accommodate usage from the tool_shed app.)
"""
try:
stmt = select(user_class).filter(user_class.username == username)
return session.execute(stmt).scalar_one()
except Exception:
return None
1 change: 1 addition & 0 deletions lib/galaxy/model/repositories/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class UserRepository(BaseRepository):
def __init__(self, session: SessionType):
super().__init__(session, User)


def get_user_by_username(session: SessionType, user_class, username: str):
"""Get a user from the database by username."""
# This may be called from the tool_shed app, which has a different
Expand Down
2 changes: 1 addition & 1 deletion lib/tool_shed/webapp/controllers/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
util,
web,
)
from galaxy.managers.users import get_user_by_username
from galaxy.model.base import transaction
from galaxy.model.repositories.user 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 (
Expand Down

0 comments on commit 0a795a6

Please sign in to comment.