Changes to fit new requirements

This commit is contained in:
zandercymatics 2024-08-07 09:24:40 -06:00
parent 5d8d01d6be
commit bf64eb2114
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
5 changed files with 37 additions and 77 deletions

View file

@ -64,7 +64,7 @@
{% endif %}
{% endif %}
{% if is_org_user %}
{% if portfolio %}
{% comment %} TODO - uncomment in #2352 and add to edit_link
{% url 'domain-suborganization' pk=domain.id as url %}
{% endcomment %}
@ -72,10 +72,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 %}

View file

@ -10,16 +10,7 @@
{% if is_editable %}
{% if portfolio %}
{% comment %} TODO - uncomment in #2352
{% with url_name="domain-suborganization" %}
{% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %}
{% endwith %}
{% endcomment %}
{% with url="#" %}
{% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %}
{% endwith %}
{% 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 %}
@ -67,9 +58,16 @@
{% endif %}
</li>
{% with url_name="domain-senior-official" %}
{% include "includes/domain_sidenav_item.html" with item_text="Senior official" %}
{% endwith %}
{% if portfolio %}
{% with url="#" %}
{% include "includes/domain_sidenav_item.html" with item_text="Suborganization" %}
{% endwith %}
{% 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 #}

View file

@ -1140,56 +1140,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_additional_permissions = [UserPortfolioPermissionChoices.VIEW_PORTFOLIO]
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

View file

@ -231,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 DomainSeniorOfficialView(DomainFormBaseView):
@ -244,19 +254,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)
org_user = self.request.user.is_org_user(self.request)
if org_user:
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
@ -283,6 +285,17 @@ 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):

View file

@ -30,10 +30,8 @@ class PortfolioDomainRequestsView(PortfolioDomainRequestsPermissionView, View):
template_name = "portfolio_requests.html"
def get(self, request):
if self.request.user.is_authenticated:
request.session["new_request"] = True
return render(request, "portfolio_requests.html")