mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 17:17:02 +02:00
clean up tamplate and fix unit tests
This commit is contained in:
parent
e82326346c
commit
d07872bfa1
3 changed files with 12 additions and 6 deletions
|
@ -2975,7 +2975,7 @@ class PortfolioAdmin(ListHeaderAdmin):
|
||||||
Will be used in the after_help_text block."""
|
Will be used in the after_help_text block."""
|
||||||
members = [user for user in obj.user.all() if "Admin" not in user.portfolio_role_summary]
|
members = [user for user in obj.user.all() if "Admin" not in user.portfolio_role_summary]
|
||||||
if not members:
|
if not members:
|
||||||
return format_html("<p>No members found.</p>")
|
return ''
|
||||||
|
|
||||||
member_details = (
|
member_details = (
|
||||||
"<table><thead><tr><th>Name</th><th>Title</th><th>Email</th>"
|
"<table><thead><tr><th>Name</th><th>Title</th><th>Email</th>"
|
||||||
|
|
|
@ -140,7 +140,13 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% elif field.field.name == "display_admins" %}
|
{% elif field.field.name == "display_admins" %}
|
||||||
<div class="readonly">{{ field.contents|safe }}</div>
|
<div class="readonly">{{ field.contents|safe }}</div>
|
||||||
{% elif field.field.name == "display_members" %}
|
{% elif field.field.name == "display_members" %}
|
||||||
<div class="readonly">{{ display_members_summary }}</div>
|
<div class="readonly">
|
||||||
|
{% if display_members_summary %}
|
||||||
|
{{ display_members_summary }}
|
||||||
|
{% else %}
|
||||||
|
<p>No members found.</p>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="readonly">{{ field.contents }}</div>
|
<div class="readonly">{{ field.contents }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -244,7 +250,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
</details>
|
</details>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% elif field.field.name == "display_members" %}
|
{% elif field.field.name == "display_members" and field.contents %}
|
||||||
<details class="margin-top-1 dja-detail-table" aria-role="button" open>
|
<details class="margin-top-1 dja-detail-table" aria-role="button" open>
|
||||||
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
||||||
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
<div class="grid-container margin-left-0 padding-left-0 padding-right-0 dja-details-contents">
|
||||||
|
|
|
@ -1233,19 +1233,19 @@ class TestUser(TestCase):
|
||||||
)
|
)
|
||||||
def test_portfolio_role_summary_member_domain_requestor_domain_manager(self):
|
def test_portfolio_role_summary_member_domain_requestor_domain_manager(self):
|
||||||
# Test if the user has 'Member', 'Domain requestor', and 'Domain manager' roles
|
# Test if the user has 'Member', 'Domain requestor', and 'Domain manager' roles
|
||||||
self.assertEqual(self.user.portfolio_role_summary, ["Member", "Domain requestor", "Domain manager"])
|
self.assertEqual(self.user.portfolio_role_summary, ["Domain requestor", "Domain manager"])
|
||||||
|
|
||||||
@patch.multiple(User, has_base_portfolio_permission=lambda self: True, has_edit_requests=lambda self: True)
|
@patch.multiple(User, has_base_portfolio_permission=lambda self: True, has_edit_requests=lambda self: True)
|
||||||
def test_portfolio_role_summary_member_domain_requestor(self):
|
def test_portfolio_role_summary_member_domain_requestor(self):
|
||||||
# Test if the user has 'Member' and 'Domain requestor' roles
|
# Test if the user has 'Member' and 'Domain requestor' roles
|
||||||
self.assertEqual(self.user.portfolio_role_summary, ["Member", "Domain requestor"])
|
self.assertEqual(self.user.portfolio_role_summary, ["Domain requestor"])
|
||||||
|
|
||||||
@patch.multiple(
|
@patch.multiple(
|
||||||
User, has_base_portfolio_permission=lambda self: True, has_domains_portfolio_permission=lambda self: True
|
User, has_base_portfolio_permission=lambda self: True, has_domains_portfolio_permission=lambda self: True
|
||||||
)
|
)
|
||||||
def test_portfolio_role_summary_member_domain_manager(self):
|
def test_portfolio_role_summary_member_domain_manager(self):
|
||||||
# Test if the user has 'Member' and 'Domain manager' roles
|
# Test if the user has 'Member' and 'Domain manager' roles
|
||||||
self.assertEqual(self.user.portfolio_role_summary, ["Member", "Domain manager"])
|
self.assertEqual(self.user.portfolio_role_summary, ["Domain manager"])
|
||||||
|
|
||||||
@patch.multiple(User, has_base_portfolio_permission=lambda self: True)
|
@patch.multiple(User, has_base_portfolio_permission=lambda self: True)
|
||||||
def test_portfolio_role_summary_member(self):
|
def test_portfolio_role_summary_member(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue