From 24126f99469423721ed2e530e2c4eb1bec0ec215 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 14 Nov 2024 15:32:42 -0500 Subject: [PATCH 01/12] breadcrumbs plus invited users on domain overview page --- src/registrar/templates/domain_add_user.html | 20 ++++++++++++++ src/registrar/templates/domain_detail.html | 23 +++++++++++++++- src/registrar/templates/domain_dns.html | 18 +++++++++++++ src/registrar/templates/domain_dnssec.html | 22 ++++++++++++++++ src/registrar/templates/domain_dsdata.html | 26 +++++++++++++++++++ .../templates/domain_nameservers.html | 22 ++++++++++++++++ .../templates/domain_security_email.html | 19 ++++++++++++++ .../templates/domain_suborganization.html | 21 +++++++++++++++ src/registrar/templates/domain_users.html | 19 ++++++++++++++ .../templates/includes/summary_item.html | 20 ++++++++++++++ 10 files changed, 209 insertions(+), 1 deletion(-) diff --git a/src/registrar/templates/domain_add_user.html b/src/registrar/templates/domain_add_user.html index fa3f8e821..1429127e6 100644 --- a/src/registrar/templates/domain_add_user.html +++ b/src/registrar/templates/domain_add_user.html @@ -5,6 +5,25 @@ {% block domain_content %} {% block breadcrumb %} + {% if portfolio %} + + + {% else %} {% url 'domain-users' pk=domain.id as url %} + {% endif %} {% endblock breadcrumb %}

Add a domain manager

{% if has_organization_feature_flag %} diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index 0fb29d2eb..a245e5f25 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -3,7 +3,24 @@ {% load custom_filters %} {% block domain_content %} + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %} + {{ block.super }} +

{{ domain.name }}

DNS name servers {% include "includes/summary_item.html" with title='Security email' value='None provided' edit_link=url editable=is_editable %} {% endif %} {% url 'domain-users' pk=domain.id as url %} - {% include "includes/summary_item.html" with title='Domain managers' users='true' list=True value=domain.permissions.all edit_link=url editable=is_editable %} + {% if portfolio %} + {% include "includes/summary_item.html" with title='Domain managers' domain_permissions=True value=domain edit_link=url editable=is_editable %} + {% else %} + {% include "includes/summary_item.html" with title='Domain managers' list=True users=True value=domain.permissions.all edit_link=url editable=is_editable %} + {% endif %}
{% endblock %} {# domain_content #} diff --git a/src/registrar/templates/domain_dns.html b/src/registrar/templates/domain_dns.html index 291319a59..9a2070c64 100644 --- a/src/registrar/templates/domain_dns.html +++ b/src/registrar/templates/domain_dns.html @@ -4,6 +4,24 @@ {% block title %}DNS | {{ domain.name }} | {% endblock %} {% block domain_content %} + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %}

DNS

diff --git a/src/registrar/templates/domain_dnssec.html b/src/registrar/templates/domain_dnssec.html index 7742a329b..cfec053c2 100644 --- a/src/registrar/templates/domain_dnssec.html +++ b/src/registrar/templates/domain_dnssec.html @@ -5,6 +5,28 @@ {% block domain_content %} + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %} +

DNSSEC

DNSSEC, or DNS Security Extensions, is an additional security layer to protect your website. Enabling DNSSEC ensures that when someone visits your domain, they can be certain that it’s connecting to the correct server, preventing potential hijacking or tampering with your domain's records.

diff --git a/src/registrar/templates/domain_dsdata.html b/src/registrar/templates/domain_dsdata.html index ba742ab09..0f60235e1 100644 --- a/src/registrar/templates/domain_dsdata.html +++ b/src/registrar/templates/domain_dsdata.html @@ -4,6 +4,32 @@ {% block title %}DS data | {{ domain.name }} | {% endblock %} {% block domain_content %} + + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %} + {% if domain.dnssecdata is None %}
diff --git a/src/registrar/templates/domain_nameservers.html b/src/registrar/templates/domain_nameservers.html index cc1fc0164..a5fd171a2 100644 --- a/src/registrar/templates/domain_nameservers.html +++ b/src/registrar/templates/domain_nameservers.html @@ -4,6 +4,28 @@ {% block title %}DNS name servers | {{ domain.name }} | {% endblock %} {% block domain_content %} + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %} + {# this is right after the messages block in the parent template #} {% for form in formset %} {% include "includes/form_errors.html" with form=form %} diff --git a/src/registrar/templates/domain_security_email.html b/src/registrar/templates/domain_security_email.html index e1755f85e..f5a58eb5d 100644 --- a/src/registrar/templates/domain_security_email.html +++ b/src/registrar/templates/domain_security_email.html @@ -4,6 +4,25 @@ {% block title %}Security email | {{ domain.name }} | {% endblock %} {% block domain_content %} + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %} + {% include "includes/form_errors.html" with form=form %}

Security email

diff --git a/src/registrar/templates/domain_suborganization.html b/src/registrar/templates/domain_suborganization.html index 67726e9d5..648563d58 100644 --- a/src/registrar/templates/domain_suborganization.html +++ b/src/registrar/templates/domain_suborganization.html @@ -4,9 +4,30 @@ {% block title %}Suborganization{% if suborganization_name %} | suborganization_name{% endif %} | {% endblock %} {% block domain_content %} + + {% block breadcrumb %} + {% if portfolio %} + + + {% endif %} + {% endblock breadcrumb %} + {# this is right after the messages block in the parent template #} {% include "includes/form_errors.html" with form=form %} +

Suborganization

diff --git a/src/registrar/templates/domain_users.html b/src/registrar/templates/domain_users.html index a2eb3e604..6e0c0896c 100644 --- a/src/registrar/templates/domain_users.html +++ b/src/registrar/templates/domain_users.html @@ -4,6 +4,25 @@ {% block title %}Domain managers | {{ domain.name }} | {% endblock %} {% block domain_content %} + {% block breadcrumb %} + {% if portfolio %} + +

+ {% endif %} + {% endblock breadcrumb %} +

Domain managers

diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index 0600d7ea7..c3b3fdd3f 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -106,6 +106,26 @@

{{ sub_header_text }}

{% endfor %} {% endif %} + {% elif domain_permissions %} + {% if value.permissions.all %} + {% if value.permissions|length == 1 %} +

{{ value.permissions.0.user.email }}

+ {% else %} +
    + {% for item in value.permissions.all %} +
  • {{ item.user.email }}
  • + {% endfor %} +
+ {% endif %} + {% endif %} + {% if value.invitations.all %} +

Invitations

+
    + {% for item in value.invitations.all %} +
  • {{ item.email }}
  • + {% endfor %} +
+ {% endif %} {% else %}

{% if value %} From b57ab6eea1a21c396ae589b93d2953c9c07266d0 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 14 Nov 2024 17:35:40 -0500 Subject: [PATCH 02/12] formatting of domain overview, invited domain mgr label --- src/registrar/assets/sass/_theme/_forms.scss | 5 +++-- src/registrar/assets/sass/_theme/_typography.scss | 7 +++++++ src/registrar/templates/includes/summary_item.html | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/registrar/assets/sass/_theme/_forms.scss b/src/registrar/assets/sass/_theme/_forms.scss index 08e35b19f..9158de174 100644 --- a/src/registrar/assets/sass/_theme/_forms.scss +++ b/src/registrar/assets/sass/_theme/_forms.scss @@ -1,5 +1,6 @@ @use "uswds-core" as *; @use "cisa_colors" as *; +@use "typography" as *; .usa-form .usa-button { margin-top: units(3); @@ -69,9 +70,9 @@ legend.float-left-tablet + button.float-right-tablet { } .read-only-label { - font-size: size('body', 'sm'); + @extend .h4--sm-05; + font-weight: bold; color: color('primary-dark'); - margin-bottom: units(0.5); } .read-only-value { diff --git a/src/registrar/assets/sass/_theme/_typography.scss b/src/registrar/assets/sass/_theme/_typography.scss index d815ef6dd..466b6f975 100644 --- a/src/registrar/assets/sass/_theme/_typography.scss +++ b/src/registrar/assets/sass/_theme/_typography.scss @@ -23,6 +23,13 @@ h2 { color: color('primary-darker'); } +.h4--sm-05 { + font-size: size('body', 'sm'); + font-weight: normal; + color: color('primary'); + margin-bottom: units(0.5); +} + // Normalize typography in forms .usa-form, .usa-form fieldset { diff --git a/src/registrar/templates/includes/summary_item.html b/src/registrar/templates/includes/summary_item.html index c3b3fdd3f..15cc0f67f 100644 --- a/src/registrar/templates/includes/summary_item.html +++ b/src/registrar/templates/includes/summary_item.html @@ -119,7 +119,7 @@

{{ sub_header_text }}

{% endif %} {% endif %} {% if value.invitations.all %} -

Invitations

+

Invited domain managers

    {% for item in value.invitations.all %}
  • {{ item.email }}
  • From 450196e7e2c54bd58119a2de4ae33cb614734688 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 14 Nov 2024 18:17:07 -0500 Subject: [PATCH 03/12] added is_portfolio_admin and custom message in domain overview for admin who is not a manager --- src/registrar/context_processors.py | 2 ++ src/registrar/models/user.py | 3 +++ src/registrar/templates/domain_detail.html | 10 +++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/registrar/context_processors.py b/src/registrar/context_processors.py index 53f6e8ae7..c2f3e6f79 100644 --- a/src/registrar/context_processors.py +++ b/src/registrar/context_processors.py @@ -68,6 +68,7 @@ def portfolio_permissions(request): "has_organization_feature_flag": False, "has_organization_requests_flag": False, "has_organization_members_flag": False, + "is_portfolio_admin": False, } try: portfolio = request.session.get("portfolio") @@ -88,6 +89,7 @@ def portfolio_permissions(request): "has_organization_feature_flag": True, "has_organization_requests_flag": request.user.has_organization_requests_flag(), "has_organization_members_flag": request.user.has_organization_members_flag(), + "is_portfolio_admin": request.user.is_portfolio_admin(portfolio), } return portfolio_context diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 80c972d38..6d4453e88 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -257,6 +257,9 @@ def has_view_suborganization_portfolio_permission(self, portfolio): def has_edit_suborganization_portfolio_permission(self, portfolio): return self._has_portfolio_permission(portfolio, UserPortfolioPermissionChoices.EDIT_SUBORGANIZATION) + def is_portfolio_admin(self, portfolio): + return self.has_edit_suborganization_portfolio_permission(portfolio) + def get_first_portfolio(self): permission = self.portfolio_permissions.first() if permission: diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index a245e5f25..c13402066 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -58,7 +58,15 @@

    {{ domain.name }}

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

    + To manage information for this domain, you must add yourself as a domain manager. +

    +
    +
    + {% elif is_portfolio_user and not is_domain_manager %}

    From 6f0bc4ce6c63eaa24f198b02af87492594679b76 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 15 Nov 2024 07:21:20 -0500 Subject: [PATCH 04/12] unit test --- src/registrar/tests/test_models.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/registrar/tests/test_models.py b/src/registrar/tests/test_models.py index 53206359b..90d74c158 100644 --- a/src/registrar/tests/test_models.py +++ b/src/registrar/tests/test_models.py @@ -824,6 +824,15 @@ def test_user_with_portfolio_roles_but_no_portfolio(self): cm.exception.message, "When portfolio roles or additional permissions are assigned, portfolio is required." ) + @less_console_noise_decorator + def test_user_with_admin_portfolio_role(self): + portfolio, _ = Portfolio.objects.get_or_create(creator=self.user, organization_name="Hotel California") + self.assertFalse(self.user.is_portfolio_admin(portfolio)) + UserPortfolioPermission.objects.get_or_create( + portfolio=portfolio, user=self.user, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN] + ) + self.assertTrue(self.user.is_portfolio_admin(portfolio)) + class TestContact(TestCase): @less_console_noise_decorator From 17fa1ae00856c0302ca8da9b04b18ffcb4e9007a Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 15 Nov 2024 08:20:17 -0500 Subject: [PATCH 05/12] view / manage button on suborganization section --- src/registrar/templates/domain_detail.html | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index c13402066..e2c2d0129 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -97,9 +97,16 @@

    DNS name servers

    {% include "includes/summary_item.html" with title='DNSSEC' value='Not Enabled' edit_link=url editable=is_editable %} {% endif %} - {% if portfolio and has_any_domains_portfolio_permission and has_view_suborganization_portfolio_permission %} - {% url 'domain-suborganization' pk=domain.id as url %} - {% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_edit_suborganization_portfolio_permission %} + {% if portfolio %} + {% if has_any_domains_portfolio_permission and has_edit_suborganization_portfolio_permission %} + {% url 'domain-suborganization' pk=domain.id as url %} + {% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_edit_suborganization_portfolio_permission %} + {% elif has_any_domains_portfolio_permission and has_view_suborganization_portfolio_permission %} + {% url 'domain-suborganization' pk=domain.id as url %} + {% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_view_suborganization_portfolio_permission view_button=True %} + + + {% endif %} {% else %} {% url 'domain-org-name-address' pk=domain.id as url %} {% include "includes/summary_item.html" with title='Organization' value=domain.domain_info address='true' edit_link=url editable=is_editable %} From a09a53e6002c32dc808fd36c4c6f330de9e8d1ca Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 15 Nov 2024 08:45:54 -0500 Subject: [PATCH 06/12] updated view tests, and linted --- src/registrar/models/user.py | 2 +- src/registrar/tests/test_views_domain.py | 39 ++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 6d4453e88..a51c0f8c6 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -259,7 +259,7 @@ def has_edit_suborganization_portfolio_permission(self, portfolio): def is_portfolio_admin(self, portfolio): return self.has_edit_suborganization_portfolio_permission(portfolio) - + def get_first_portfolio(self): permission = self.portfolio_permissions.first() if permission: diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index a375493be..453f79481 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -6,7 +6,7 @@ from django.contrib.auth import get_user_model from waffle.testutils import override_flag from api.tests.common import less_console_noise_decorator -from registrar.models.utility.portfolio_helper import UserPortfolioRoleChoices +from registrar.models.utility.portfolio_helper import UserPortfolioPermissionChoices, UserPortfolioRoleChoices from .common import MockEppLib, MockSESClient, create_user # type: ignore from django_webtest import WebTest # type: ignore import boto3_mocking # type: ignore @@ -342,7 +342,10 @@ def test_domain_readonly_on_detail_page(self): DomainInformation.objects.get_or_create(creator=user, domain=domain, portfolio=portfolio) UserPortfolioPermission.objects.get_or_create( - user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN] + user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_MEMBER], + additional_permissions=[ + UserPortfolioPermissionChoices.VIEW_ALL_DOMAINS, + ], ) user.refresh_from_db() self.client.force_login(user) @@ -357,6 +360,38 @@ def test_domain_readonly_on_detail_page(self): # Check that user does not have option to Edit domain self.assertNotContains(detail_page, "Edit") + @less_console_noise_decorator + @override_flag("organization_feature", active=True) + def test_domain_readonly_on_detail_page_for_org_admin_not_manager(self): + """Test that a domain, which is part of a portfolio, but for which the user is not a domain manager, + properly displays read only""" + + portfolio, _ = Portfolio.objects.get_or_create(organization_name="Test org", creator=self.user) + # need to create a different user than self.user because the user needs permission assignments + user = get_user_model().objects.create( + first_name="Test", + last_name="User", + email="bogus@example.gov", + phone="8003111234", + title="test title", + ) + domain, _ = Domain.objects.get_or_create(name="bogusdomain.gov") + DomainInformation.objects.get_or_create(creator=user, domain=domain, portfolio=portfolio) + + UserPortfolioPermission.objects.get_or_create( + user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN] + ) + user.refresh_from_db() + self.client.force_login(user) + detail_page = self.client.get(f"/domain/{domain.id}") + # Check that alert message displays properly + self.assertContains( + detail_page, + "To manage information for this domain, you must add yourself as a domain manager.", + ) + # Check that user does not have option to Edit domain + self.assertNotContains(detail_page, "Edit") + class TestDomainManagers(TestDomainOverview): @classmethod From 837d618015b662c4850affeb44d2c7ba542e369f Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 15 Nov 2024 08:52:50 -0500 Subject: [PATCH 07/12] linted some more --- 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 453f79481..98d0df038 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -342,7 +342,9 @@ def test_domain_readonly_on_detail_page(self): DomainInformation.objects.get_or_create(creator=user, domain=domain, portfolio=portfolio) UserPortfolioPermission.objects.get_or_create( - user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_MEMBER], + user=user, + portfolio=portfolio, + roles=[UserPortfolioRoleChoices.ORGANIZATION_MEMBER], additional_permissions=[ UserPortfolioPermissionChoices.VIEW_ALL_DOMAINS, ], From 8f18a409ea8243f53fc9f26177f2a43d844138f4 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 18 Nov 2024 13:51:39 -0500 Subject: [PATCH 08/12] added logic to not display blue info box in certain condition, and added test --- src/registrar/templates/domain_detail.html | 30 ++++++++++++---------- src/registrar/tests/test_views_domain.py | 21 +++++++++++++++ 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index e2c2d0129..36025bc31 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -58,22 +58,24 @@

    {{ domain.name }}

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

    - To manage information for this domain, you must add yourself as a domain manager. -

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

    + To manage information for this domain, you must add yourself as a domain manager. +

    +
    -
    - {% elif 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. -

    + {% elif is_portfolio_user and not is_domain_manager and not is_analyst_managing_domain %} +
    +
    +

    + 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 fcb03deb4..fc7df00b1 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -323,6 +323,27 @@ 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(): + # have to use staff user for this test + staff_user = create_user() + # staff_user.save() + 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 051efe798d798f38f585b0c676237c8040874ccc Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 18 Nov 2024 14:07:34 -0500 Subject: [PATCH 09/12] oops undo accidental commit --- src/registrar/templates/domain_detail.html | 31 ++++++++++------------ src/registrar/tests/test_views_domain.py | 21 --------------- 2 files changed, 14 insertions(+), 38 deletions(-) diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index 36025bc31..f322e501e 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -58,27 +58,24 @@

    {{ domain.name }}

    {% include "includes/domain_dates.html" %} - {% if analyst_action != 'edit' or analyst_action_location != domain.pk %} - {% if is_portfolio_admin and not is_domain_manager and not is_analyst_managing_domain %} -
    -
    -

    - To manage information for this domain, you must add yourself as a domain manager. -

    -
    + {% if is_portfolio_admin and not is_domain_manager %} +
    +
    +

    + To manage information for this domain, you must add yourself as a domain manager. +

    - {% elif is_portfolio_user and not is_domain_manager and not is_analyst_managing_domain %} -
    -
    -

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

    -
    +
    + {% elif 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 %} - {% url 'domain-dns-nameservers' pk=domain.id as url %} {% if domain.nameservers|length > 0 %} {% include "includes/summary_item.html" with title='DNS name servers' domains='true' value=domain.nameservers list='true' edit_link=url editable=is_editable %} diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index fc7df00b1..fcb03deb4 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -323,27 +323,6 @@ 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(): - # have to use staff user for this test - staff_user = create_user() - # staff_user.save() - 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 9c0a7e15e8bd7eea5a13ae177fcb472bfe875c6c Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 26 Nov 2024 19:56:46 -0500 Subject: [PATCH 10/12] added some additional test code to boost coverage, fixed is_portfolio_admin, and formatting --- src/registrar/models/user.py | 2 +- src/registrar/templates/domain_detail.html | 2 +- src/registrar/tests/test_views_domain.py | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/registrar/models/user.py b/src/registrar/models/user.py index 473641d29..6c9c37c92 100644 --- a/src/registrar/models/user.py +++ b/src/registrar/models/user.py @@ -259,7 +259,7 @@ def has_edit_suborganization_portfolio_permission(self, portfolio): return self._has_portfolio_permission(portfolio, UserPortfolioPermissionChoices.EDIT_SUBORGANIZATION) def is_portfolio_admin(self, portfolio): - return self.has_edit_suborganization_portfolio_permission(portfolio) + return "Admin" in self.portfolio_role_summary(portfolio) def get_first_portfolio(self): permission = self.portfolio_permissions.first() diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index d6d4ee3c3..57463028d 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -20,7 +20,6 @@ {% endblock breadcrumb %} {{ block.super }} -

    {{ domain.name }}

    {{ domain.name }} {% endif %} {% endif %} + {% url 'domain-dns-nameservers' pk=domain.id as url %} {% if domain.nameservers|length > 0 %} {% include "includes/summary_item.html" with title='DNS name servers' domains='true' value=domain.nameservers list='true' edit_link=url editable=is_editable %} diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index 39b9ed241..b0c1fca1f 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -142,6 +142,7 @@ def setUp(self): def tearDown(self): try: UserDomainRole.objects.all().delete() + DomainInvitation.objects.all().delete() if hasattr(self.domain, "contacts"): self.domain.contacts.all().delete() DomainRequest.objects.all().delete() @@ -382,6 +383,8 @@ def test_domain_readonly_on_detail_page(self): ) # Check that user does not have option to Edit domain self.assertNotContains(detail_page, "Edit") + # Check that invited domain manager section not displayed when no invited domain managers + self.assertNotContains(detail_page, "Invited domain managers") @less_console_noise_decorator @override_flag("organization_feature", active=True) @@ -404,6 +407,8 @@ def test_domain_readonly_on_detail_page_for_org_admin_not_manager(self): UserPortfolioPermission.objects.get_or_create( user=user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN] ) + # add a domain invitation + DomainInvitation.objects.get_or_create(email="invited@example.com", domain=domain) user.refresh_from_db() self.client.force_login(user) detail_page = self.client.get(f"/domain/{domain.id}") @@ -414,6 +419,9 @@ def test_domain_readonly_on_detail_page_for_org_admin_not_manager(self): ) # Check that user does not have option to Edit domain self.assertNotContains(detail_page, "Edit") + # Check that invited domain manager is displayed + self.assertContains(detail_page, "Invited domain managers") + self.assertContains(detail_page, "invited@example.com") class TestDomainManagers(TestDomainOverview): From 471388ddf89f99a50f67be5ad8a6e03c2fec0c0f Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Tue, 26 Nov 2024 20:06:52 -0500 Subject: [PATCH 11/12] formatting removing spaces --- src/registrar/templates/domain_detail.html | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index 57463028d..6d7ded66d 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -77,7 +77,7 @@

    {{ domain.name }}

    {% endif %} {% endif %} - + {% url 'domain-dns-nameservers' pk=domain.id as url %} {% if domain.nameservers|length > 0 %} {% include "includes/summary_item.html" with title='DNS name servers' domains='true' value=domain.nameservers list='true' edit_link=url editable=is_editable %} @@ -105,13 +105,10 @@

    DNS name servers

    {% elif has_any_domains_portfolio_permission and has_view_suborganization_portfolio_permission %} {% url 'domain-suborganization' pk=domain.id as url %} {% include "includes/summary_item.html" with title='Suborganization' value=domain.domain_info.sub_organization edit_link=url editable=is_editable|and:has_view_suborganization_portfolio_permission view_button=True %} - - {% endif %} {% else %} {% url 'domain-org-name-address' pk=domain.id as url %} {% include "includes/summary_item.html" with title='Organization' value=domain.domain_info address='true' edit_link=url editable=is_editable %} - {% url 'domain-senior-official' pk=domain.id as url %} {% include "includes/summary_item.html" with title='Senior official' value=domain.domain_info.senior_official contact='true' edit_link=url editable=is_editable %} {% endif %} From a007826e170515631919339fea2eaee836365720 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Wed, 27 Nov 2024 11:11:54 -0500 Subject: [PATCH 12/12] updated messaging --- src/registrar/templates/domain_detail.html | 10 +--------- src/registrar/tests/test_views_domain.py | 4 ++-- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index 6d7ded66d..add7ca725 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -58,15 +58,7 @@

    {{ domain.name }}

    {% include "includes/domain_dates.html" %} {% if analyst_action != 'edit' or analyst_action_location != domain.pk %} - {% if is_portfolio_admin and not is_domain_manager %} -
    -
    -

    - To manage information for this domain, you must add yourself as a domain manager. -

    -
    -
    - {% elif is_portfolio_user and not is_domain_manager %} + {% if is_portfolio_user and not is_domain_manager %}

    diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index b0c1fca1f..25e8b0fb6 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -342,7 +342,7 @@ 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." + detail_page, "If you need to make updates, contact one of the listed domain managers." ) @less_console_noise_decorator @@ -415,7 +415,7 @@ def test_domain_readonly_on_detail_page_for_org_admin_not_manager(self): # Check that alert message displays properly self.assertContains( detail_page, - "To manage information for this domain, you must add yourself as a domain manager.", + "If you need to make updates, contact one of the listed domain managers.", ) # Check that user does not have option to Edit domain self.assertNotContains(detail_page, "Edit")