From b2b680f15d3d57211ba570e05e9acb0acaa96103 Mon Sep 17 00:00:00 2001 From: Mike Fiedler Date: Mon, 30 Dec 2024 11:41:41 -0500 Subject: [PATCH] feat: add owner details to observation reports (#17324) --- tests/unit/observations/test_tasks.py | 5 ++++- warehouse/observations/tasks.py | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/tests/unit/observations/test_tasks.py b/tests/unit/observations/test_tasks.py index 88159df65cab..bb1108e4df93 100644 --- a/tests/unit/observations/test_tasks.py +++ b/tests/unit/observations/test_tasks.py @@ -20,7 +20,7 @@ ) from ...common.db.accounts import UserFactory -from ...common.db.packaging import ProjectFactory +from ...common.db.packaging import ProjectFactory, RoleFactory def test_execute_observation_report(app_config): @@ -55,6 +55,9 @@ def test_report_observation_to_helpscout( user = UserFactory.create() db_request.user = user project = ProjectFactory.create() + project_owner = UserFactory.create() + RoleFactory.create(project=project, user=project_owner, role_name="Owner") + observation = project.record_observation( request=db_request, kind=kind, diff --git a/warehouse/observations/tasks.py b/warehouse/observations/tasks.py index 74151b8028f2..171b27cd88da 100644 --- a/warehouse/observations/tasks.py +++ b/warehouse/observations/tasks.py @@ -85,9 +85,14 @@ def report_observation_to_helpscout(task, request: Request, model_id: UUID) -> N Summary: {model.summary} Model Name: {model.__class__.__name__} - Project URL: https://pypi.org/project/{target_name}/ + Project URL: {request.route_url('packaging.project', name=target_name)} """ ) + for owner in model.related.owners: + username = owner.username + owner_url = request.route_url("admin.user.detail", username=username) + convo_text += f"Owner: {username}\n" + convo_text += f"Owner URL: {owner_url}\n" if OBSERVATION_KIND_MAP[model.kind] == ObservationKind.IsMalware: convo_text += dedent(