- Add an entity-search directive for adding a nice search box for users or teams

- Add support for team-based permissions to the repos
This commit is contained in:
Joseph Schorr 2013-11-01 21:48:10 -04:00
parent 09afe0753f
commit 100ec563fa
7 changed files with 362 additions and 93 deletions

View file

@ -207,8 +207,13 @@ def get_user(username):
return None
def get_matching_teams(team_prefix, organization):
query = Team.select().where(Team.name ** (team_prefix + '%'), Team.organization == organization)
return list(query.limit(10))
def get_matching_users(username_prefix):
query = User.select().where(User.username ** (username_prefix + '%'))
query = User.select().where(User.username ** (username_prefix + '%'), User.organization == False)
return list(query.limit(10))
@ -328,6 +333,15 @@ def get_all_user_permissions(user):
return with_role.where(User.username == user.username)
def get_all_repo_teams(namespace_name, repository_name):
select = RepositoryPermission.select(Team.name.alias('team_name'), Role.name,
RepositoryPermission)
with_team = select.join(Team)
with_role = with_team.switch(RepositoryPermission).join(Role)
with_repo = with_role.switch(RepositoryPermission).join(Repository)
return with_repo.where(Repository.namespace == namespace_name,
Repository.name == repository_name)
def get_all_repo_users(namespace_name, repository_name):
select = RepositoryPermission.select(User.username, Role.name,
RepositoryPermission)