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

feat: add owner details to observation reports #17324

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/unit/observations/test_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion warehouse/observations/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down