Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

profile: add archived projects section #17571

Merged
merged 10 commits into from
Feb 12, 2025
11 changes: 6 additions & 5 deletions tests/unit/accounts/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,11 @@ def test_user_redirects_username(self, db_request):

def test_returns_user(self, db_request):
user = UserFactory.create()
assert views.profile(user, db_request) == {"user": user, "projects": []}
assert views.profile(user, db_request) == {
"user": user,
"projects": [],
"archived_projects": [],
}

def test_user_profile_queries_once_for_all_projects(
self, db_request, query_recorder
Expand Down Expand Up @@ -4039,10 +4043,7 @@ def test_add_pending_github_oidc_publisher_too_many_already(
]
assert db_request.session.flash.calls == [
pretend.call(
(
"You can't register more than 3 pending trusted "
"publishers at once."
),
("You can't register more than 3 pending trusted publishers at once."),
woodruffw marked this conversation as resolved.
Show resolved Hide resolved
queue="error",
)
]
Expand Down
26 changes: 19 additions & 7 deletions warehouse/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
from warehouse.packaging.interfaces import IProjectService
from warehouse.packaging.models import (
JournalEntry,
LifecycleStatus,
Project,
Release,
Role,
Expand Down Expand Up @@ -185,6 +186,7 @@ def profile(user, request):
select(
Project.name,
Project.normalized_name,
Project.lifecycle_status,
Release.created,
Release.summary,
)
Expand All @@ -206,17 +208,28 @@ def profile(user, request):
)

# Construct the list of projects with their latest releases from query results
projects = [
{
archived_projects = []
live_projects = []

for row in request.db.execute(stmt):
project = {
"name": row.name,
"normalized_name": row.normalized_name,
"lifecycle_status": row.lifecycle_status,
"created": row.created,
"summary": row.summary,
}
for row in request.db.execute(stmt)
]

return {"user": user, "projects": projects}
if row.lifecycle_status == LifecycleStatus.Archived:
archived_projects.append(project)
miketheman marked this conversation as resolved.
Show resolved Hide resolved
else:
live_projects.append(project)

return {
"user": user,
"projects": live_projects,
miketheman marked this conversation as resolved.
Show resolved Hide resolved
"archived_projects": archived_projects,
}


@view_config(
Expand Down Expand Up @@ -1640,8 +1653,7 @@ def _add_pending_oidc_publisher(
if len(self.request.user.pending_oidc_publishers) >= 3:
self.request.session.flash(
self.request._(
"You can't register more than 3 pending trusted "
"publishers at once."
"You can't register more than 3 pending trusted publishers at once."
),
queue="error",
)
Expand Down
Loading
Loading