Skip to content

Commit

Permalink
[feature] transition the package_roles method onto the restful API
Browse files Browse the repository at this point in the history
These changes adds the `package_roles` as results of the return of the
`admin.views.project` restful API.

The `package_roles` method was available into the xmlrpc, unfortunately
these informations are missing into the restful API [1].

These changes adds the creation of an equivalent into the restful API.

[1] pypi#9700
  • Loading branch information
4383 committed Jul 8, 2021
1 parent 4299bb1 commit 9be11ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/unit/admin/views/test_projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_gets_project(self, db_request):
"project": project,
"releases": [],
"maintainers": roles,
"package_roles": [],
"journal": journals[:30],
"ONE_MB": views.ONE_MB,
"MAX_FILESIZE": views.MAX_FILESIZE,
Expand Down
11 changes: 11 additions & 0 deletions warehouse/admin/views/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ def project_detail(project, request):
)
]
maintainers = sorted(maintainers, key=lambda x: (x.role_name, x.user.username))
package_roles = [
role
for role in (
request.db.query(Role)
.join(User, Project)
.filter(Project.normalized_name == project)
.order_by(Role.role_name.desc(), User.username)
.all()
)
]
journal = [
entry
for entry in (
Expand All @@ -126,6 +136,7 @@ def project_detail(project, request):
"project": project,
"releases": releases,
"maintainers": maintainers,
"package_roles": package_roles,
"journal": journal,
"ONE_MB": ONE_MB,
"MAX_FILESIZE": MAX_FILESIZE,
Expand Down

0 comments on commit 9be11ba

Please sign in to comment.