From 5256e2cc8ce7505f708a1a0532798a3e438bfbbc Mon Sep 17 00:00:00 2001 From: Helder Ribeiro Date: Wed, 13 Nov 2024 17:32:19 +0000 Subject: [PATCH 1/2] fmd-984 - Remove `data owner` references from app code - replaced `data_owner` with `data_custodian` in the codebase - did not replace any reference to data owner on datahub lib Signed-off-by: Helder Ribeiro --- feedback/models.py | 2 +- feedback/service.py | 6 +++--- feedback/views.py | 4 ++-- templates/partial/contact_info.html | 2 +- tests/feedback/test_notify_service.py | 8 ++++---- tests/feedback/test_views.py | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/feedback/models.py b/feedback/models.py index 73c128ec..5998bacc 100644 --- a/feedback/models.py +++ b/feedback/models.py @@ -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) diff --git a/feedback/service.py b/feedback/service.py index 5c4bd727..859963c1 100644 --- a/feedback/service.py +++ b/feedback/service.py @@ -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, @@ -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, ) diff --git a/feedback/views.py b/feedback/views.py index 033b6833..1fc0adfe 100644 --- a/feedback/views.py +++ b/feedback/views.py @@ -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 @@ -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() diff --git a/templates/partial/contact_info.html b/templates/partial/contact_info.html index b34f9f3f..a38c16d6 100644 --- a/templates/partial/contact_info.html +++ b/templates/partial/contact_info.html @@ -69,6 +69,6 @@

{% translate "Data custodian {% if NOTIFY_ENABLED and entity_name %} {% endif %} diff --git a/tests/feedback/test_notify_service.py b/tests/feedback/test_notify_service.py index 08b5f307..b342fd20 100644 --- a/tests/feedback/test_notify_service.py +++ b/tests/feedback/test_notify_service.py @@ -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": "entity_owner@justice.gov.uk", + "data_custodian_email": "entity_owner@justice.gov.uk", "created_by": reporter, } @@ -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.", @@ -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": "entity_owner@justice.gov.uk", + "data_custodian_email": "entity_owner@justice.gov.uk", } issue = Issue.objects.create(**data) @@ -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 = { diff --git a/tests/feedback/test_views.py b/tests/feedback/test_views.py index 779125e5..4807e7b2 100644 --- a/tests/feedback/test_views.py +++ b/tests/feedback/test_views.py @@ -36,7 +36,7 @@ def test_form_renders(self, client): data={ "entity_name": "my_entity", "entity_url": "http://localhost/my_entity", - "data_owner_email": "data.owner@justice.gov.uk", + "data_custodian_email": "data.owner@justice.gov.uk", }, ) assert response.status_code == 200 From b4cd5adace09abcff9d7e2f75d8ebea2283af424 Mon Sep 17 00:00:00 2001 From: Helder Ribeiro Date: Mon, 18 Nov 2024 11:34:25 +0000 Subject: [PATCH 2/2] fmd-984 - update migrations Signed-off-by: Helder Ribeiro --- .../migrations/0003_alter_issue_reason.py | 27 ++++++++++++++++ ...ail_issue_data_custodian_email_and_more.py | 32 +++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 feedback/migrations/0003_alter_issue_reason.py create mode 100644 feedback/migrations/0004_rename_data_owner_email_issue_data_custodian_email_and_more.py diff --git a/feedback/migrations/0003_alter_issue_reason.py b/feedback/migrations/0003_alter_issue_reason.py new file mode 100644 index 00000000..d86fb5bf --- /dev/null +++ b/feedback/migrations/0003_alter_issue_reason.py @@ -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?", + ), + ), + ] diff --git a/feedback/migrations/0004_rename_data_owner_email_issue_data_custodian_email_and_more.py b/feedback/migrations/0004_rename_data_owner_email_issue_data_custodian_email_and_more.py new file mode 100644 index 00000000..9c0b1d0f --- /dev/null +++ b/feedback/migrations/0004_rename_data_owner_email_issue_data_custodian_email_and_more.py @@ -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?", + ), + ), + ]