Skip to content

Commit b2b680f

Browse files
authored
feat: add owner details to observation reports (#17324)
1 parent 114b846 commit b2b680f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tests/unit/observations/test_tasks.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
)
2121

2222
from ...common.db.accounts import UserFactory
23-
from ...common.db.packaging import ProjectFactory
23+
from ...common.db.packaging import ProjectFactory, RoleFactory
2424

2525

2626
def test_execute_observation_report(app_config):
@@ -55,6 +55,9 @@ def test_report_observation_to_helpscout(
5555
user = UserFactory.create()
5656
db_request.user = user
5757
project = ProjectFactory.create()
58+
project_owner = UserFactory.create()
59+
RoleFactory.create(project=project, user=project_owner, role_name="Owner")
60+
5861
observation = project.record_observation(
5962
request=db_request,
6063
kind=kind,

warehouse/observations/tasks.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,14 @@ def report_observation_to_helpscout(task, request: Request, model_id: UUID) -> N
8585
Summary: {model.summary}
8686
Model Name: {model.__class__.__name__}
8787
88-
Project URL: https://pypi.org/project/{target_name}/
88+
Project URL: {request.route_url('packaging.project', name=target_name)}
8989
"""
9090
)
91+
for owner in model.related.owners:
92+
username = owner.username
93+
owner_url = request.route_url("admin.user.detail", username=username)
94+
convo_text += f"Owner: {username}\n"
95+
convo_text += f"Owner URL: {owner_url}\n"
9196

9297
if OBSERVATION_KIND_MAP[model.kind] == ObservationKind.IsMalware:
9398
convo_text += dedent(

0 commit comments

Comments
 (0)