Fix a bug where users in a different org would not show up in the entity search.
This commit is contained in:
parent
af697efba3
commit
e23bee99ec
1 changed files with 10 additions and 8 deletions
|
@ -386,7 +386,6 @@ def get_matching_teams(team_prefix, organization):
|
||||||
|
|
||||||
def get_matching_users(username_prefix, robot_namespace=None,
|
def get_matching_users(username_prefix, robot_namespace=None,
|
||||||
organization=None):
|
organization=None):
|
||||||
Org = User.alias()
|
|
||||||
direct_user_query = (User.username ** (username_prefix + '%') &
|
direct_user_query = (User.username ** (username_prefix + '%') &
|
||||||
(User.organization == False) & (User.robot == False))
|
(User.organization == False) & (User.robot == False))
|
||||||
|
|
||||||
|
@ -396,22 +395,25 @@ def get_matching_users(username_prefix, robot_namespace=None,
|
||||||
(User.username ** (robot_prefix + '%') &
|
(User.username ** (robot_prefix + '%') &
|
||||||
(User.robot == True)))
|
(User.robot == True)))
|
||||||
|
|
||||||
query = User.select(User.username, Org.username, User.robot).where(direct_user_query)
|
query = (User
|
||||||
|
.select(User.username, Team.id, User.robot)
|
||||||
|
.where(direct_user_query))
|
||||||
|
|
||||||
if organization:
|
if organization:
|
||||||
with_team = query.join(TeamMember, JOIN_LEFT_OUTER).join(Team,
|
query = (query
|
||||||
JOIN_LEFT_OUTER)
|
.join(TeamMember, JOIN_LEFT_OUTER)
|
||||||
with_org = with_team.join(Org, JOIN_LEFT_OUTER,
|
.join(Team, JOIN_LEFT_OUTER, on=((Team.id == TeamMember.team) &
|
||||||
on=(Org.id == Team.organization))
|
(Team.organization == organization))))
|
||||||
query = with_org.where((Org.id == organization) | (Org.id >> None))
|
|
||||||
|
|
||||||
|
|
||||||
class MatchingUserResult(object):
|
class MatchingUserResult(object):
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
logger.debug("tuple: %s" % str(args))
|
||||||
|
|
||||||
self.username = args[0]
|
self.username = args[0]
|
||||||
self.is_robot = args[2]
|
self.is_robot = args[2]
|
||||||
if organization:
|
if organization:
|
||||||
self.is_org_member = (args[1] == organization.username)
|
self.is_org_member = (args[1] != None)
|
||||||
else:
|
else:
|
||||||
self.is_org_member = None
|
self.is_org_member = None
|
||||||
|
|
||||||
|
|
Reference in a new issue