diff --git a/data/model/legacy.py b/data/model/legacy.py index f34ef7cae..4ae304cfb 100644 --- a/data/model/legacy.py +++ b/data/model/legacy.py @@ -1156,18 +1156,27 @@ def update_email(user, new_email, auto_verify=False): def get_all_user_permissions(user): UserThroughTeam = User.alias() - return (RepositoryPermission - .select(RepositoryPermission, Role, Repository, Namespace) - .join(Role) - .switch(RepositoryPermission) - .join(Repository) - .join(Namespace, on=(Repository.namespace_user == Namespace.id)) - .switch(RepositoryPermission) - .join(User, JOIN_LEFT_OUTER) - .switch(RepositoryPermission) - .join(Team, JOIN_LEFT_OUTER).join(TeamMember, JOIN_LEFT_OUTER) - .join(UserThroughTeam, JOIN_LEFT_OUTER, on=(UserThroughTeam.id == TeamMember.user)) - .where((User.id == user) | (UserThroughTeam.id == user))) + base_query = (RepositoryPermission + .select(RepositoryPermission, Role, Repository, Namespace) + .join(Role) + .switch(RepositoryPermission) + .join(Repository) + .join(Namespace, on=(Repository.namespace_user == Namespace.id)) + .switch(RepositoryPermission)) + + direct = (base_query + .clone() + .join(User) + .where(User.id == user)) + + team = (base_query + .clone() + .join(Team) + .join(TeamMember) + .join(UserThroughTeam, on=(UserThroughTeam.id == TeamMember.user)) + .where(UserThroughTeam.id == user)) + + return direct | team def delete_prototype_permission(org, uid): @@ -1232,7 +1241,7 @@ def get_org_wide_permissions(user): def get_all_repo_teams(namespace_name, repository_name): - return (RepositoryPermission.select(Team.name.alias('team_name'), Role.name, RepositoryPermission) + return (RepositoryPermission.select(Team.name, Role.name, RepositoryPermission) .join(Team) .switch(RepositoryPermission) .join(Role) diff --git a/requirements-nover.txt b/requirements-nover.txt index 52f3ea6b0..7712cc755 100644 --- a/requirements-nover.txt +++ b/requirements-nover.txt @@ -1,7 +1,6 @@ autobahn==0.9.3-3 aiowsgi trollius -peewee flask py-bcrypt Flask-Principal @@ -40,6 +39,7 @@ git+https://github.com/DevTable/anunidecode.git git+https://github.com/DevTable/pygithub.git git+https://github.com/DevTable/container-cloud-config.git git+https://github.com/DevTable/python-etcd.git@sslfix +git+https://github.com/coreos/peewee.git git+https://github.com/coreos/py-bitbucket.git git+https://github.com/coreos/pyapi-gitlab.git git+https://github.com/coreos/mockldap.git diff --git a/requirements.txt b/requirements.txt index cf4fd0f73..3eb60de18 100644 --- a/requirements.txt +++ b/requirements.txt @@ -56,7 +56,6 @@ oslo.serialization==1.5.0 oslo.utils==1.5.0 paramiko==1.15.2 pbr==0.11.0 -peewee==2.6.0 prettytable==0.7.2 psutil==2.2.1 psycopg2==2.6 @@ -95,6 +94,7 @@ git+https://github.com/DevTable/pygithub.git git+https://github.com/DevTable/container-cloud-config.git git+https://github.com/DevTable/python-etcd.git@sslfix git+https://github.com/NateFerrero/oauth2lib.git +git+https://github.com/coreos/peewee.git git+https://github.com/coreos/py-bitbucket.git git+https://github.com/coreos/pyapi-gitlab.git git+https://github.com/coreos/mockldap.git \ No newline at end of file