Fix filtering of repos only visible to org admins
This commit is contained in:
parent
bf6b0c9299
commit
b4939a3cd0
2 changed files with 66 additions and 1 deletions
|
@ -34,6 +34,11 @@ def get_public_repo_visibility():
|
|||
return Visibility.get(name='public')
|
||||
|
||||
|
||||
@lru_cache(maxsize=3)
|
||||
def _lookup_team_role(name):
|
||||
return TeamRole.get(name=name)
|
||||
|
||||
|
||||
def filter_to_repos_for_user(query, username=None, namespace=None, include_public=True,
|
||||
start_id=None):
|
||||
if not include_public and not username:
|
||||
|
@ -85,7 +90,7 @@ def filter_to_repos_for_user(query, username=None, namespace=None, include_publi
|
|||
.switch(Repository)
|
||||
.join(Org, on=(Repository.namespace_user == Org.id))
|
||||
.join(AdminTeam, on=(Org.id == AdminTeam.organization))
|
||||
.join(TeamRole, on=(AdminTeam.role == TeamRole.id))
|
||||
.where(AdminTeam.role == _lookup_team_role('admin'))
|
||||
.switch(AdminTeam)
|
||||
.join(AdminTeamMember, on=(AdminTeam.id == AdminTeamMember.team))
|
||||
.join(AdminUser, on=(AdminTeamMember.user == AdminUser.id))
|
||||
|
|
Reference in a new issue