Make sure also include teams from organizations that the user admins
This commit is contained in:
parent
a34d56045f
commit
1b56567268
2 changed files with 45 additions and 1 deletions
|
@ -696,7 +696,26 @@ def get_matching_user_teams(team_prefix, user):
|
|||
.switch(Team)
|
||||
.join(TeamMember)
|
||||
.where(TeamMember.user == user, Team.name ** (team_prefix + '%'))
|
||||
.distinct(Team.id)
|
||||
.limit(10))
|
||||
|
||||
return query
|
||||
|
||||
|
||||
def get_matching_admined_teams(team_prefix, user):
|
||||
admined_orgs = (get_user_organizations(user.username)
|
||||
.switch(Team)
|
||||
.join(TeamRole)
|
||||
.where(TeamRole.name == 'admin'))
|
||||
|
||||
query = (Team.select()
|
||||
.join(User)
|
||||
.switch(Team)
|
||||
.join(TeamMember)
|
||||
.where(Team.name ** (team_prefix + '%'), Team.organization << (admined_orgs))
|
||||
.distinct(Team.id)
|
||||
.limit(10))
|
||||
|
||||
return query
|
||||
|
||||
|
||||
|
|
Reference in a new issue