diff --git a/src/registrar/templates/domain_detail.html b/src/registrar/templates/domain_detail.html index af7fee363..2e1d31d74 100644 --- a/src/registrar/templates/domain_detail.html +++ b/src/registrar/templates/domain_detail.html @@ -71,10 +71,11 @@ {% else %} {% url 'domain-org-name-address' pk=domain.id as url %} {% include "includes/summary_item.html" with title='Organization name and mailing address' 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 %} - {% 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 %} {# Conditionally display profile #} {% if not has_profile_feature_flag %} diff --git a/src/registrar/templates/domain_sidebar.html b/src/registrar/templates/domain_sidebar.html index fad2d82a0..f2e9f190c 100644 --- a/src/registrar/templates/domain_sidebar.html +++ b/src/registrar/templates/domain_sidebar.html @@ -10,14 +10,7 @@ {% if is_editable %} - {% if portfolio %} - {% comment %} Only show this menu option if the user has the perms to do so {% endcomment %} - {% if has_domains_portfolio_permission and request.user.has_view_suborganization %} - {% with url_name="domain-suborganization" %} - {% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %} - {% endwith %} - {% endif %} - {% else %} + {% if not portfolio %} {% with url_name="domain-org-name-address" %} {% include "includes/domain_sidenav_item.html" with item_text="Organization name and mailing address" %} {% endwith %} @@ -65,9 +58,19 @@ {% endif %} - {% with url_name="domain-senior-official" %} - {% include "includes/domain_sidenav_item.html" with item_text="Senior official" %} - {% endwith %} + + {% if portfolio %} + {% comment %} Only show this menu option if the user has the perms to do so {% endcomment %} + {% if has_domains_portfolio_permission and request.user.has_view_suborganization %} + {% with url_name="domain-suborganization" %} + {% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %} + {% endwith %} + {% endif %} + {% else %} + {% with url_name="domain-senior-official" %} + {% include "includes/domain_sidenav_item.html" with item_text="Senior official" %} + {% endwith %} + {% endif %} {% if not has_profile_feature_flag %} {# Conditionally display profile link in main nav #} diff --git a/src/registrar/tests/test_views_domain.py b/src/registrar/tests/test_views_domain.py index de9cd5c0a..5ff69f55b 100644 --- a/src/registrar/tests/test_views_domain.py +++ b/src/registrar/tests/test_views_domain.py @@ -36,7 +36,6 @@ from registrar.models import ( FederalAgency, Portfolio, Suborganization, - SeniorOfficial, ) from datetime import date, datetime, timedelta from django.utils import timezone @@ -1140,56 +1139,6 @@ class TestDomainSeniorOfficial(TestDomainOverview): page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id})) self.assertContains(page, "Testy") - @override_flag("organization_feature", active=True) - def test_domain_senior_official_content_profile_feature(self): - """A portfolios senior official appears on the page - when the organization_feature flag is on.""" - - # Add a SO to the domain information object - self.domain_information.senior_official = Contact(first_name="Testy") - self.domain_information.senior_official.save() - self.domain_information.save() - - # Add a portfolio to the current domain - portfolio = Portfolio.objects.create(creator=self.user, organization_name="Ice Cream") - _suborg = Suborganization.objects.create(portfolio=portfolio, name="Vanilla") - - # Add the portfolio to the domain_information object - self.domain_information.portfolio = portfolio - self.domain_information.save() - self.domain_information.refresh_from_db() - - # Add portfolio perms to the user object - self.user.portfolio = portfolio - self.user.portfolio_roles = [UserPortfolioRoleChoices.ORGANIZATION_ADMIN] - self.user.save() - self.user.refresh_from_db() - - # Add a SO to the portfolio - senior_official = SeniorOfficial.objects.create(first_name="Bob", last_name="Unoriginal") - portfolio.senior_official = senior_official - portfolio.save() - portfolio.refresh_from_db() - - # The page should not contain the SO on domain information. - # However, the page should contain the SO on portfolio - page = self.app.get(reverse("domain-senior-official", kwargs={"pk": self.domain.id})) - - # Make sure that we're in the portfolio "view". - # This also implicity tests that the flag is working. - self.assertContains(page, "Suborganization") - self.assertNotContains(page, "Organization name") - - # Make sure that we're using the right SO value. - self.assertNotContains(page, "Testy") - self.assertContains(page, "Bob") - - # Cleanup - self.domain_information.delete() - _suborg.delete() - portfolio.delete() - senior_official.delete() - @less_console_noise_decorator def test_domain_edit_senior_official_in_place(self): """When editing a senior official for domain information and SO is not diff --git a/src/registrar/views/domain.py b/src/registrar/views/domain.py index 296e9c448..949d580bd 100644 --- a/src/registrar/views/domain.py +++ b/src/registrar/views/domain.py @@ -23,7 +23,6 @@ from registrar.models import ( DomainInvitation, User, UserDomainRole, - Portfolio, PublicContact, ) from registrar.utility.enums import DefaultEmail @@ -232,6 +231,16 @@ class DomainOrgNameAddressView(DomainFormBaseView): # superclass has the redirect return super().form_valid(form) + def has_permission(self): + """Override for the has_permission class to exclude portfolio users""" + + # Org users shouldn't have access to this page + is_org_user = self.request.user.is_org_user(self.request) + if self.request.user.portfolio and is_org_user: + return False + else: + return super().has_permission() + class DomainSubOrganizationView(DomainFormBaseView): """Suborganization view""" @@ -272,17 +281,11 @@ class DomainSeniorOfficialView(DomainFormBaseView): def get_form_kwargs(self, *args, **kwargs): """Add domain_info.senior_official instance to make a bound form.""" form_kwargs = super().get_form_kwargs(*args, **kwargs) - if self.request.user.is_org_user(self.request): - portfolio = Portfolio.objects.filter(information_portfolio=self.object.domain_info).first() - senior_official = portfolio.senior_official if portfolio else None - else: - senior_official = self.object.domain_info.senior_official - form_kwargs["instance"] = senior_official + form_kwargs["instance"] = self.object.domain_info.senior_official domain_info = self.get_domain_info_from_domain() invalid_fields = [DomainRequest.OrganizationChoices.FEDERAL, DomainRequest.OrganizationChoices.TRIBAL] is_federal_or_tribal = domain_info and (domain_info.generic_org_type in invalid_fields) - form_kwargs["disable_fields"] = is_federal_or_tribal return form_kwargs @@ -310,6 +313,16 @@ class DomainSeniorOfficialView(DomainFormBaseView): # superclass has the redirect return super().form_valid(form) + def has_permission(self): + """Override for the has_permission class to exclude portfolio users""" + + # Org users shouldn't have access to this page + is_org_user = self.request.user.is_org_user(self.request) + if self.request.user.portfolio and is_org_user: + return False + else: + return super().has_permission() + class DomainDNSView(DomainBaseView): """DNS Information View."""