From ddb7ed2d6cee925384376b2c51727cec5ac73aa4 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 18 Nov 2024 13:59:20 -0500 Subject: [PATCH 1/2] added logic to not display blue info box in certain condition, and added test --- src/registrar/templates/domain_detail.html | 16 +++++++++------- src/registrar/tests/test_views_domain.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index 0fb29d2eb0..96ec4c5b67 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -41,14 +41,16 @@

{{ domain.name }}

{% include "includes/domain_dates.html" %} - {% if is_portfolio_user and not is_domain_manager %} -
-
-

- You don't have access to manage {{domain.name}}. If you need to make updates, contact one of the listed domain managers. -

+ {% if analyst_action != 'edit' or analyst_action_location != domain.pk %} + {% if is_portfolio_user and not is_domain_manager %} +
+
+

+ You don't have access to manage {{domain.name}}. If you need to make updates, contact one of the listed domain managers. +

+
-
+ {% endif %} {% endif %} diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index 1b77312226..6ba3bbb940 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -323,6 +323,25 @@ def test_domain_detail_with_no_information_or_domain_request(self): self.assertContains(detail_page, "noinformation.gov") self.assertContains(detail_page, "Domain missing domain information") + def test_domain_detail_with_analyst_managing_domain(self): + """Test that domain management page returns 200 and does not display + blue error message when an analyst is managing the domain""" + with less_console_noise(): + staff_user = create_user() + self.client.force_login(staff_user) + + # need to set the analyst_action and analyst_action_location + # in the session to emulate user clicking Manage Domain + # in the admin interface + session = self.client.session + session["analyst_action"] = "edit" + session["analyst_action_location"] = self.domain.id + session.save() + + detail_page = self.client.get(reverse("domain", kwargs={"pk": self.domain.id})) + + self.assertNotContains(detail_page, "To manage information for this domain, you must add yourself as a domain manager.") + @less_console_noise_decorator @override_flag("organization_feature", active=True) def test_domain_readonly_on_detail_page(self): From 6a0c48328842f73d1845bbc6bc51c515fb595319 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 18 Nov 2024 14:11:30 -0500 Subject: [PATCH 2/2] formatted code for readability --- src/registrar/tests/test_views_domain.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index 6ba3bbb940..b4a96d127c 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -340,7 +340,9 @@ def test_domain_detail_with_analyst_managing_domain(self): detail_page = self.client.get(reverse("domain", kwargs={"pk": self.domain.id})) - self.assertNotContains(detail_page, "To manage information for this domain, you must add yourself as a domain manager.") + self.assertNotContains( + detail_page, "To manage information for this domain, you must add yourself as a domain manager." + ) @less_console_noise_decorator @override_flag("organization_feature", active=True)