#3866 - Add Organization admins to the Organization overview page - [meoward] (#3928)

Added logic to existing summary_item.html
Added statement to pull portfolio admins in view, portfolios.py, for summary_item.html display
Changed porfolio_suborganization.html to reflect requirements of ticket
This commit is contained in:
Abe Alam 2025-07-18 10:10:46 -04:00 committed by GitHub
parent 033d628eac
commit aed8b9b2b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 132 additions and 104 deletions

View file

@ -1,7 +1,9 @@
{% load static url_helpers %} {% load static url_helpers %}
{% if portfolio_first_section %} <section class="summary-item margin-top-2"> {% if portfolio_first_section %}
{% else %} <section class="summary-item margin-top-3"> <section class="summary-item margin-top-2">
{% else %}
<section class="summary-item margin-top-3">
{% endif %} {% endif %}
<hr class="" aria-hidden="true" /> <hr class="" aria-hidden="true" />
<div class="display-flex flex-justify"> <div class="display-flex flex-justify">
@ -20,120 +22,137 @@
{% else %} {% else %}
</h3> </h3>
{% endif %} {% endif %}
{% if sub_header_text %}
<h4 class="margin-bottom-0">{{ sub_header_text }}</h4> {# To display default styling for sub-header text and organization information in organization overview #}
{% if sub_header_text %}
<h4 class="margin-bottom-0">{{ sub_header_text }}</h4>
{% if sub_header_text == "Organization Admins" %}
<ul class="usa-list">
{% for admin in portfolio_admins %}
<li>{{ admin.get_full_name|default:admin.username }}</li>
{% empty %}
<li>No admins assigned.</li>
{% endfor %}
</ul>
<h4 class="margin-bottom-2">Organization Name and Address</h4>
{% endif %} {% endif %}
{% if permissions %} {% endif %}
{% include "includes/member_permissions_summary.html" with permissions=value %}
{% elif domain_mgmt %} {% if permissions %}
{% include "includes/member_domain_management.html" with domain_count=value %} {% include "includes/member_permissions_summary.html" with permissions=value %}
{% elif address %}
{% include "includes/organization_address.html" with organization=value %} {% elif domain_mgmt %}
{% elif contact %} {% include "includes/member_domain_management.html" with domain_count=value %}
{% if list %}
{% if value|length == 1 %} {% elif address %}
{% include "includes/contact.html" with contact=value|first %} {% include "includes/organization_address.html" with organization=value %}
{% elif contact %}
{% if list %}
{% if value|length == 1 %}
{% include "includes/contact.html" with contact=value|first %}
{% else %}
{% if value %}
<dl class="usa-list usa-list--unstyled margin-top-0">
{% for item in value %}
<dt>
<h4 class="margin-bottom-05 padding-right-1">
Contact {{forloop.counter}}
</h4>
</dt>
<dd>
{% include "includes/contact.html" with contact=item %}
</dd>
{% endfor %}
</dl>
{% elif custom_text_for_value_none %}
<p>
{{ custom_text_for_value_none }}
</p>
{% else %} {% else %}
{% if value %} <p>
<dl class="usa-list usa-list--unstyled margin-top-0"> None
{% for item in value %} </p>
<dt> {% endif %}
{% endif %}
<h4 class=" {% else %}
margin-bottom-05 {% include "includes/contact.html" with contact=value %}
padding-right-1"> {% endif %}
Contact {{forloop.counter}}
</h4> {% elif list %}
</dt> {% if value|length == 1 %}
<dd> {% if users %}
{% include "includes/contact.html" with contact=item %} <p class="margin-top-0">{{ value.0.user.email }} </p>
</dd> {% elif domains %}
{% endfor %} {{ value.0.0 }}
</dl> {% if value.0.1 %}
{% elif custom_text_for_value_none %} ({% spaceless %}
<p> {% for addr in value.0.1 %}
{{ custom_text_for_value_none }} {{addr}}{% if not forloop.last %}, {% endif %}
</p> {% endfor %}
{% else %} {% endspaceless %})
<p>
None
</p>
{% endif %}
{% endif %} {% endif %}
{% else %} {% else %}
{% include "includes/contact.html" with contact=value %} <p class="margin-top-0 margin-bottom-0">{{ value | first }} </p>
{% endif %} {% endif %}
{% elif list %} {% else %}
{% if value|length == 1 %} <ul class="usa-list usa-list--unstyled margin-top-0">
{% if users %} {% for item in value %}
<p class="margin-top-0">{{ value.0.user.email }} </p> {% if users %}
{% elif domains %} <li>{{ item.user.email }}</li>
{{ value.0.0 }} {% elif domains %}
{% if value.0.1 %} <li>
{{ item.0 }}
{% if item.1 %}
({% spaceless %} ({% spaceless %}
{% for addr in value.0.1 %} {% for addr in item.1 %}
{{addr}}{% if not forloop.last %}, {% endif %} {{addr}}{% if not forloop.last %}, {% endif %}
{% endfor %} {% endfor %}
{% endspaceless %}) {% endspaceless %})
{% endif %} {% endif %}
{% else %} </li>
<p class="margin-top-0 margin-bottom-0">{{ value | first }} </p> {% else %}
{% endif %} <li>{{ item }}</li>
{% endif %}
{% empty %}
<li>None</li>
{% endfor %}
</ul>
{% endif %}
{% elif domain_permissions %}
{% if value.permissions.all %}
{% if value.permissions|length == 1 %}
<p class="margin-top-0">{{ value.permissions.0.user.email }} </p>
{% else %} {% else %}
<ul class="usa-list usa-list--unstyled margin-top-0"> <ul class="usa-list usa-list--unstyled margin-top-0">
{% for item in value %} {% for item in value.permissions.all %}
{% if users %} <li>{{ item.user.email }}</li>
<li>{{ item.user.email }}</li>
{% elif domains %}
<li>
{{ item.0 }}
{% if item.1 %}
({% spaceless %}
{% for addr in item.1 %}
{{addr}}{% if not forloop.last %}, {% endif %}
{% endfor %}
{% endspaceless %})
{% endif %}
</li>
{% else %}
<li>{{ item }}</li>
{% endif %}
{% empty %}
<li>None</li>
{% endfor %}
</ul>
{% endif %}
{% elif domain_permissions %}
{% if value.permissions.all %}
{% if value.permissions|length == 1 %}
<p class="margin-top-0">{{ value.permissions.0.user.email }} </p>
{% else %}
<ul class="usa-list usa-list--unstyled margin-top-0">
{% for item in value.permissions.all %}
<li>{{ item.user.email }}</li>
{% endfor %}
</ul>
{% endif %}
{% endif %}
{% if value.active_invitations.all %}
<h4 class="margin-bottom-05">Invited domain managers</h4>
<ul class="usa-list usa-list--unstyled margin-top-0">
{% for item in value.active_invitations.all %}
<li>{{ item.email }}</li>
{% endfor %} {% endfor %}
</ul> </ul>
{% endif %} {% endif %}
{% else %}
{% if custom_text_for_value_none %}
<p class="margin-top-0 text-base-dark">{{ custom_text_for_value_none }}</p>
{% endif %}
{% if value %}
{{ value }}
{% endif %}
{% if not value %}
None
{% endif %}
{% endif %} {% endif %}
{% if value.active_invitations.all %}
<h4 class="margin-bottom-05">Invited domain managers</h4>
<ul class="usa-list usa-list--unstyled margin-top-0">
{% for item in value.active_invitations.all %}
<li>{{ item.email }}</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
{% if custom_text_for_value_none %}
<p class="margin-top-0 text-base-dark">{{ custom_text_for_value_none }}</p>
{% endif %}
{% if value %}
{{ value }}
{% endif %}
{% if not value %}
None
{% endif %}
{% endif %}
</div> </div>
{% comment %}We have conditions where an edit_link is set but editable can be true or false{% endcomment %} {% comment %}We have conditions where an edit_link is set but editable can be true or false{% endcomment %}
@ -159,6 +178,5 @@
</div> </div>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div>
</div>
</section> </section>

View file

@ -20,8 +20,8 @@
<div class="margin-top-2 tablet:grid-col-10"> <div class="margin-top-2 tablet:grid-col-10">
<h2 class="string-wrap margin-top-2">{{ portfolio }}</h2> <h2 class="string-wrap margin-top-2">{{ portfolio }}</h2>
{% url 'organization-info' as url %} {% url 'organization-info' as url %}
{% include "includes/summary_item.html" with title='Organization' value=portfolio address='true' edit_link=url editable=has_edit_portfolio_permission view_button='true' portfolio_first_section='true'%} {% include "includes/summary_item.html" with title='Organization' value=portfolio address='true' sub_header_text='Organization Admins' edit_link=url editable=has_edit_portfolio_permission view_button='true' portfolio_first_section='true' %}
{% url 'organization-senior-official' as url %} {% url 'organization-senior-official' as url %}
{% include "includes/summary_item.html" with title='Senior official' value=portfolio.senior_official contact='true' edit_link=url view_button='true' %} {% include "includes/summary_item.html" with title='Senior official' value=portfolio.senior_official contact='true' edit_link=url view_button='true' %}
</div> </div>

View file

@ -212,6 +212,13 @@ class TestPortfolio(WebTest):
first_name="Saturn", last_name="Enceladus", title="Planet/Moon", email="spacedivision@igorville.com" first_name="Saturn", last_name="Enceladus", title="Planet/Moon", email="spacedivision@igorville.com"
) )
portfolio_admin = User.objects.create_user(
username="adminuser", first_name="Galileo", last_name="Galilei", email="admin@example.com"
)
UserPortfolioPermission.objects.create(
user=portfolio_admin, portfolio=self.portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN]
)
self.portfolio.senior_official = so self.portfolio.senior_official = so
self.portfolio.organization_name = "Hotel California" self.portfolio.organization_name = "Hotel California"
self.portfolio.city = "Los Angeles" self.portfolio.city = "Los Angeles"
@ -227,6 +234,8 @@ class TestPortfolio(WebTest):
# Organization overview page includes organization info and senior official details # Organization overview page includes organization info and senior official details
self.assertContains(response, "Los Angeles") self.assertContains(response, "Los Angeles")
self.assertContains(response, "spacedivision@igorville.com") self.assertContains(response, "spacedivision@igorville.com")
# Organization overview page includes portfolio admin
self.assertContains(response, "Galileo")
@less_console_noise_decorator @less_console_noise_decorator
def test_portfolio_organization_page_directs_to_org_detail_forms(self): def test_portfolio_organization_page_directs_to_org_detail_forms(self):

View file

@ -904,6 +904,7 @@ class PortfolioOrganizationView(DetailView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
portfolio = self.request.session.get("portfolio") portfolio = self.request.session.get("portfolio")
context["has_edit_portfolio_permission"] = self.request.user.has_edit_portfolio_permission(portfolio) context["has_edit_portfolio_permission"] = self.request.user.has_edit_portfolio_permission(portfolio)
context["portfolio_admins"] = portfolio.portfolio_admin_users
return context return context
def get_object(self, queryset=None): def get_object(self, queryset=None):