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

Fmd 984 replace owner refs from app #1045

Merged
merged 2 commits into from
Nov 19, 2024
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
27 changes: 27 additions & 0 deletions feedback/migrations/0003_alter_issue_reason.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 5.1.3 on 2024-11-14 14:56

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("feedback", "0002_remove_issue_user_email_issue_created_by"),
]

operations = [
migrations.AlterField(
model_name="issue",
name="reason",
field=models.CharField(
choices=[
("Link is broken", "Broken Link"),
("Data Custodian is incorrect", "Incorrect Custodian"),
("Contact is outdated", "Outdated Contact"),
("Other", "Other"),
],
max_length=50,
verbose_name="What is wrong with this page?",
),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Generated by Django 5.1.3 on 2024-11-18 11:23

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("feedback", "0003_alter_issue_reason"),
]

operations = [
migrations.RenameField(
model_name="issue",
old_name="data_owner_email",
new_name="data_custodian_email",
),
migrations.AlterField(
model_name="issue",
name="reason",
field=models.CharField(
choices=[
("Link is broken", "Broken Link"),
("Data custodian is incorrect", "Incorrect Custodian"),
("Contact is outdated", "Outdated Contact"),
("Other", "Other"),
],
max_length=50,
verbose_name="What is wrong with this page?",
),
),
]
2 changes: 1 addition & 1 deletion feedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ class IssueChoices(models.TextChoices):
)
entity_name = models.CharField(max_length=250)
entity_url = models.CharField(max_length=250)
data_owner_email = models.CharField(max_length=250)
data_custodian_email = models.CharField(max_length=250)
6 changes: 3 additions & 3 deletions feedback/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def send(

personalisation = {
"assetOwner": (
issue.data_owner_email if issue.data_owner_email else "Data Catalog Team"
issue.data_custodian_email if issue.data_custodian_email else "Data Catalog Team"
),
"userEmail": issue.created_by.email if issue.created_by else "",
"assetName": issue.entity_name,
Expand All @@ -39,11 +39,11 @@ def send(
reference = str(issue.id)

# Notify Data Owner
if issue.data_owner_email:
if issue.data_custodian_email:
notify(
personalisation=personalisation,
template_id=settings.NOTIFY_DATA_OWNER_TEMPLATE_ID,
email_address=issue.data_owner_email,
email_address=issue.data_custodian_email,
reference=reference,
client=client,
)
Expand Down
4 changes: 2 additions & 2 deletions feedback/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def report_issue_view(request) -> HttpResponse:
issue = form.save(commit=False)
issue.entity_name = request.session.get("entity_name")
issue.entity_url = request.session.get("entity_url")
issue.data_owner_email = request.session.get("data_owner_email")
issue.data_custodian_email = request.session.get("data_custodian_email")

# in production, there should always be a signed in user,
# but this may not be the case in local development/unit tests
Expand Down Expand Up @@ -81,7 +81,7 @@ def report_issue_view(request) -> HttpResponse:

request.session["entity_name"] = entity_name
request.session["entity_url"] = entity_url
request.session["data_owner_email"] = _(request.GET.get("data_owner_email", ""))
request.session["data_custodian_email"] = _(request.GET.get("data_custodian_email", ""))

form = IssueForm()

Expand Down
2 changes: 1 addition & 1 deletion templates/partial/contact_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ <h2 class="govuk-heading-s govuk-!-margin-bottom-1">{% translate "Data custodian

{% if NOTIFY_ENABLED and entity_name %}
<div class="govuk-body">
<a type="button" class="govuk-button" href="{% url 'feedback:report-issue' %}?entity_name={{ entity_name }}&data_owner_email={{ data_owner_email }}&entity_url={{ request.build_absolute_uri}}" class="govuk-link">Report an issue</a>
<a type="button" class="govuk-button" href="{% url 'feedback:report-issue' %}?entity_name={{ entity_name }}&data_custodian_email={{ data_custodian_email }}&entity_url={{ request.build_absolute_uri}}" class="govuk-link">Report an issue</a>
</div>
{% endif %}
8 changes: 4 additions & 4 deletions tests/feedback/test_notify_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def test_send_all_notifications(mock_notifications_client, reporter):
"additional_info": "This is some additional information.",
"entity_name": "my_entity",
"entity_url": "http://localhost/my_entity",
"data_owner_email": "[email protected]",
"data_custodian_email": "[email protected]",
"created_by": reporter,
}

Expand All @@ -24,7 +24,7 @@ def test_send_all_notifications(mock_notifications_client, reporter):


@pytest.mark.django_db
def test_send_notifications_no_data_owner_email(mock_notifications_client, reporter):
def test_send_notifications_no_data_custodian_email(mock_notifications_client, reporter):
data = {
"reason": "Other",
"additional_info": "This is some additional information.",
Expand All @@ -48,7 +48,7 @@ def test_send_all_notifications_no_reporter(mock_notifications_client):
"additional_info": "This is some additional information.",
"entity_name": "my_entity",
"entity_url": "http://localhost/my_entity",
"data_owner_email": "[email protected]",
"data_custodian_email": "[email protected]",
}

issue = Issue.objects.create(**data)
Expand All @@ -59,7 +59,7 @@ def test_send_all_notifications_no_reporter(mock_notifications_client):


@pytest.mark.django_db
def test_send_all_notifications_no_reporter_no_data_owner_email(
def test_send_all_notifications_no_reporter_no_data_custodian_email(
mock_notifications_client, reporter
):
data = {
Expand Down
2 changes: 1 addition & 1 deletion tests/feedback/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_form_renders(self, client):
data={
"entity_name": "my_entity",
"entity_url": "http://localhost/my_entity",
"data_owner_email": "[email protected]",
"data_custodian_email": "[email protected]",
},
)
assert response.status_code == 200
Expand Down