From 500dc77bb3ccbc35aa8ddb06b46009b0a6b50fb9 Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Fri, 8 Oct 2021 17:56:16 -0400 Subject: [PATCH] Fix bug on UserGroupAssoc mapping (see note) This is the same bug as the one fixed on the main model in https://github.com/galaxyproject/galaxy/commit/174d8b53ac4d48ac6950c579539537da42a6a2e8 --- lib/tool_shed/grids/admin_grids.py | 4 ++-- lib/tool_shed/webapp/model/__init__.py | 2 +- lib/tool_shed/webapp/model/mapping.py | 2 +- lib/tool_shed/webapp/security/__init__.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/tool_shed/grids/admin_grids.py b/lib/tool_shed/grids/admin_grids.py index e686ed16eed..8e3ac87665e 100644 --- a/lib/tool_shed/grids/admin_grids.py +++ b/lib/tool_shed/grids/admin_grids.py @@ -259,8 +259,8 @@ class GroupGrid(grids.Grid): class UsersColumn(grids.GridColumn): def get_value(self, trans, grid, group): - if group.members: - return len(group.members) + if group.users: + return len(group.users) return 0 title = "Groups" diff --git a/lib/tool_shed/webapp/model/__init__.py b/lib/tool_shed/webapp/model/__init__.py index eb2127a3668..8981754636d 100644 --- a/lib/tool_shed/webapp/model/__init__.py +++ b/lib/tool_shed/webapp/model/__init__.py @@ -174,7 +174,7 @@ class Group(Base, Dictifiable, _HasTable): name = Column(String(255), index=True, unique=True) deleted = Column(Boolean, index=True, default=False) roles = relationship('GroupRoleAssociation', back_populates='group') - users = relationship('UserGroupAssociation') # TODO: fix bug: incorrect usage of backref/duplicate rel users/members; add back_populates + users = relationship('UserGroupAssociation', back_populates='group') dict_collection_visible_keys = ['id', 'name'] dict_element_visible_keys = ['id', 'name'] diff --git a/lib/tool_shed/webapp/model/mapping.py b/lib/tool_shed/webapp/model/mapping.py index 45c3e23d051..e5e3492081f 100644 --- a/lib/tool_shed/webapp/model/mapping.py +++ b/lib/tool_shed/webapp/model/mapping.py @@ -108,7 +108,7 @@ mapper_registry.map_imperatively(RepositoryRoleAssociation, RepositoryRoleAssoci mapper_registry.map_imperatively(UserGroupAssociation, UserGroupAssociation.table, properties=dict(user=relation(User, backref="groups"), - group=relation(Group, backref="members"))) # TODO fix bug: members should be users; check codebase for references + group=relation(Group, back_populates="users"))) mapper_registry.map_imperatively(UserRoleAssociation, UserRoleAssociation.table, properties=dict( diff --git a/lib/tool_shed/webapp/security/__init__.py b/lib/tool_shed/webapp/security/__init__.py index f794ffad19b..c5ba9486aa5 100644 --- a/lib/tool_shed/webapp/security/__init__.py +++ b/lib/tool_shed/webapp/security/__init__.py @@ -234,7 +234,7 @@ class CommunityRBACAgent(RBACAgent): # of a group that is associated with the role. for gra in role.groups: group = gra.group - for uga in group.members: + for uga in group.users: member = uga.user if member.id == user.id: return True