@@ -24,35 +20,36 @@ https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/
{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
{% if field.is_checkbox %}
+ {# .gov override #}
{% block field_checkbox %}
{{ field.field }}{{ field.label_tag }}
{% endblock field_checkbox%}
{% else %}
{{ field.label_tag }}
{% if field.is_readonly %}
+ {# .gov override #}
{% block field_readonly %}
{{ field.contents }}
{% endblock field_readonly%}
{% else %}
+ {# .gov override #}
{% block field_other %}
{{ field.field }}
{% endblock field_other%}
{% endif %}
{% endif %}
-
- {% block before_help_text %}
- {# For templating purposes #}
- {% endblock before_help_text %}
{% if field.field.help_text %}
+ {# .gov override #}
{% block help_text %}
{{ field.field.help_text|safe }}
{% endblock help_text %}
{% endif %}
-
+
+ {# .gov addition #}
{% block after_help_text %}
{# For templating purposes #}
{% endblock after_help_text %}
diff --git a/src/registrar/templates/django/admin/domain_information_change_form.html b/src/registrar/templates/django/admin/domain_information_change_form.html
index 86475890d..f58ee2239 100644
--- a/src/registrar/templates/django/admin/domain_information_change_form.html
+++ b/src/registrar/templates/django/admin/domain_information_change_form.html
@@ -3,6 +3,13 @@
{% block field_sets %}
{% for fieldset in adminform %}
+ {% comment %}
+ TODO: this will eventually need to be changed to something like this
+ if we ever want to customize this file:
{% include "django/admin/includes/domain_information_fieldset.html" %}
+
+ Use detail_table_fieldset as an example, or just extend it.
+ {% endcomment %}
+ {% include "django/admin/includes/detail_table_fieldset.html" %}
{% endfor %}
{% endblock %}
diff --git a/src/registrar/templates/django/admin/domain_request_change_form.html b/src/registrar/templates/django/admin/domain_request_change_form.html
index 5d5e6ed60..b0ee6e044 100644
--- a/src/registrar/templates/django/admin/domain_request_change_form.html
+++ b/src/registrar/templates/django/admin/domain_request_change_form.html
@@ -4,8 +4,16 @@
{% block field_sets %}
{# Create an invisible
tag so that we can use a click event to toggle the modal. #}
+
{% for fieldset in adminform %}
- {% include "django/admin/includes/domain_request_fieldset.html" %}
+ {% comment %}
+ TODO: this will eventually need to be changed to something like this
+ if we ever want to customize this file:
+ {% include "django/admin/includes/domain_information_fieldset.html" %}
+
+ Use detail_table_fieldset as an example, or just extend it.
+ {% endcomment %}
+ {% include "django/admin/includes/detail_table_fieldset.html" %}
{% endfor %}
{% endblock %}
diff --git a/src/registrar/templates/django/admin/includes/contact_detail_list.html b/src/registrar/templates/django/admin/includes/contact_detail_list.html
new file mode 100644
index 000000000..6afe4c8d6
--- /dev/null
+++ b/src/registrar/templates/django/admin/includes/contact_detail_list.html
@@ -0,0 +1,51 @@
+{% load i18n static %}
+
+
+
+ {% if show_formatted_name %}
+ {% if contact.get_formatted_name %}
+ {{ user.get_formatted_name }}
+ {% else %}
+ None
+ {% endif %}
+ {% endif %}
+
+ {% if user.title or user.contact.title or user.email or user.contact.email or user.phone or user.contact.phone %}
+ {# Title #}
+ {% if user.title or user.contact.title %}
+ {% if user.contact.title %}
+ {{ user.contact.title }}
+ {% else %}
+ {{ user.title }}
+ {% endif %}
+
+ {% else %}
+ None
+ {% endif %}
+ {# Email #}
+ {% if user.email or user.contact.email %}
+ {% if user.contact.email %}
+ {{ user.contact.email }}
+ {% else %}
+ {{ user.email }}
+ {% endif %}
+
+ {% else %}
+ None
+ {% endif %}
+
+ {# Phone #}
+ {% if user.phone or user.contact.phone %}
+ {% if user.contact.phone %}
+ {{ user.contact.phone }}
+ {% else %}
+ {{ user.phone }}
+ {% endif %}
+
+ {% else %}
+ None
+ {% endif %}
+ {% else %}
+ No additional contact information found.
+ {% endif %}
+
diff --git a/src/registrar/templates/django/admin/includes/detail_table_fieldset.html b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html
index 3d9d038d6..47145faf2 100644
--- a/src/registrar/templates/django/admin/includes/detail_table_fieldset.html
+++ b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html
@@ -5,72 +5,102 @@
This is using a custom implementation fieldset.html (see admin/fieldset.html)
{% endcomment %}
{% block field_readonly %}
+ {% with all_contacts=original.other_contacts.all %}
{% if field.field.name == "other_contacts" %}
-
- {% for contact in field.contents|split:", " %}
-
{{ contact }}{% if not forloop.last %}, {% endif %}
- {% endfor %}
-
+ {% if all_contacts.count > 2 %}
+
+ {% else %}
+
+
+ {% for contact in all_contacts %}
+ -
+ Organization contact {{forloop.counter}}
+
+ -
+ {% include "django/admin/includes/contact_detail_list.html" with user=contact show_formatted_name=True %}
+
+ {% endfor %}
+
+
+ {% endif %}
{% elif field.field.name == "current_websites" %}
- {% comment %}
- The "website" model is essentially just a text field.
- It is not useful to be redirected to the object definition,
- rather it is more useful in this scenario to be redirected to the
- actual website (as its just a plaintext string otherwise).
+ {% comment %}
+ The "website" model is essentially just a text field.
+ It is not useful to be redirected to the object definition,
+ rather it is more useful in this scenario to be redirected to the
+ actual website (as its just a plaintext string otherwise).
- This ONLY applies to analysts. For superusers, its business as usual.
- {% endcomment %}
- {% for website in field.contents|split:", " %}
-
{{ website }}{% if not forloop.last %}, {% endif %}
- {% endfor %}
+ This ONLY applies to analysts. For superusers, its business as usual.
+ {% endcomment %}
+
+ {% with total_websites=field.contents|split:", " %}
+ {% for website in total_websites %}
+
{{ website }}{% if not forloop.last %}, {% endif %}
+ {# Acts as a
#}
+ {% if total_websites|length < 5 %}
+
+ {% endif %}
+ {% endfor %}
+ {% endwith %}
+
+ {% elif field.field.name == "alternative_domains" %}
+
+ {% for alt_domain in original.alternative_domains.all %}
+
{{ alt_domain }}{% if not forloop.last %}, {% endif %}
+ {% endfor %}
+
{% else %}
{{ field.contents }}
{% endif %}
+ {% endwith %}
{% endblock field_readonly %}
{% block after_help_text %}
{% if field.field.name == "creator" %}
- {% include "django/admin/includes/contact_detail_table.html" with user=original.creator field_name="creator" %}
+
+
+ {% include "django/admin/includes/contact_detail_list.html" with user=original.creator no_title_top_padding=field.is_readonly %}
+
{% elif field.field.name == "submitter" %}
- {% include "django/admin/includes/contact_detail_table.html" with user=original.submitter field_name="submitter" %}
+
+
+ {% include "django/admin/includes/contact_detail_list.html" with user=original.submitter no_title_top_padding=field.is_readonly %}
+
{% elif field.field.name == "authorizing_official" %}
- {% include "django/admin/includes/contact_detail_table.html" with user=original.authorizing_official field_name="authorizing_official" %}
+
+
+ {% include "django/admin/includes/contact_detail_list.html" with user=original.authorizing_official no_title_top_padding=field.is_readonly %}
+
{% elif field.field.name == "other_contacts" and original.other_contacts.all %}
-
- Details
-
-
-
- {% for contact in original.other_contacts.all %}
- {% comment %}
- Since we can't get the id from field, we can embed this information here.
- Then we can link these two fields using javascript.
- {% endcomment %}
-
- {{contact.first_name}} {{contact.last_name}} |
- {{ contact.title }} |
- {{ contact.email }} |
- {{ contact.phone }} |
- {# Copy button for the email #}
-
-
-
- |
-
- {% endfor %}
-
-
-
-
+ {% with all_contacts=original.other_contacts.all %}
+ {% if all_contacts.count > 2 %}
+
+ Details
+
+
+
+
+ Other contact information |
+
+
+
+ {% for contact in all_contacts %}
+
+ {{ contact.get_formatted_name }} |
+ {{ contact.title }} |
+ {{ contact.email }} |
+ {{ contact.phone }} |
+
+ {% endfor %}
+
+
+
+
+ {% endif %}
+ {% endwith %}
{% endif %}
{% endblock after_help_text %}
diff --git a/src/registrar/templates/django/admin/includes/domain_information_fieldset.html b/src/registrar/templates/django/admin/includes/domain_information_fieldset.html
deleted file mode 100644
index b42873c3c..000000000
--- a/src/registrar/templates/django/admin/includes/domain_information_fieldset.html
+++ /dev/null
@@ -1,2 +0,0 @@
-{% extends "django/admin/includes/detail_table_fieldset.html" %}
-{# Stubbed file for future expansion #}
diff --git a/src/registrar/templates/django/admin/includes/domain_request_fieldset.html b/src/registrar/templates/django/admin/includes/domain_request_fieldset.html
deleted file mode 100644
index b42873c3c..000000000
--- a/src/registrar/templates/django/admin/includes/domain_request_fieldset.html
+++ /dev/null
@@ -1,2 +0,0 @@
-{% extends "django/admin/includes/detail_table_fieldset.html" %}
-{# Stubbed file for future expansion #}
diff --git a/src/registrar/tests/test_admin.py b/src/registrar/tests/test_admin.py
index 2e4e6dfc6..bbbf385d9 100644
--- a/src/registrar/tests/test_admin.py
+++ b/src/registrar/tests/test_admin.py
@@ -1300,17 +1300,13 @@ class TestDomainRequestAdmin(MockEppLib):
# == Check for the creator == #
# Check for the right title, email, and phone number in the response.
- # We only need to check for the end tag
- # (Otherwise this test will fail if we change classes, etc)
expected_email = "meoward.jones@igorville.gov"
expected_creator_fields = [
# Field, expected value
- ("title", "Treat inspector"),
- ("email", f"{expected_email}"),
- # Check for the existence of the copy button input.
- # Lets keep things simple to minimize future conflicts.
+ ("title", "Treat inspector"),
+ ("email", "meoward.jones@igorville.gov"),
+ ("phone", "(555) 123 12345"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_creator_fields)
@@ -1321,10 +1317,10 @@ class TestDomainRequestAdmin(MockEppLib):
expected_email = "mayor@igorville.gov"
expected_submitter_fields = [
# Field, expected value
- ("title", "Admin Tester"),
- ("email", f"{expected_email}"),
+ ("title", "Admin Tester"),
+ ("email", "mayor@igorville.gov"),
+ ("phone", "(555) 555 5556"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields)
self.assertContains(response, "Testy2 Tester2")
@@ -1334,42 +1330,27 @@ class TestDomainRequestAdmin(MockEppLib):
expected_ao_fields = [
# Field, expected value
("title", "Chief Tester"),
- ("email", f"{expected_email}"),
- ("email_copy_button_input", f'
"),
("phone", "(555) 555 5555"),
+ ("email_copy_button_input", f'
", count=3)
-
- # Email. Count=3 because this table appears on three records.
- self.assertContains(response, "Email", count=3)
-
- # Phone. Count=3 because this table appears on three records.
- self.assertContains(response, "Phone", count=3)
+ self.assertContains(response, "Testy Tester", count=5)
# == Test the other_employees field == #
expected_email = "testy@town.com"
expected_other_employees_fields = [
# Field, expected value
- ("title", "Another Tester"),
- ("email", f"{expected_email}"),
+ ("title", "Another Tester"),
+ ("email", "testy2@town.com"),
+ ("phone", "(555) 555 5557"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields)
- # count=1 as only one should exist in a table
- self.assertContains(response, "Testy Tester", count=1)
-
def test_save_model_sets_restricted_status_on_user(self):
with less_console_noise():
# make sure there is no user with this email
@@ -1453,6 +1434,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.assertContains(response, "Yes, select ineligible status")
def test_readonly_when_restricted_creator(self):
+ self.maxDiff = None
with less_console_noise():
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
@@ -1465,6 +1447,9 @@ class TestDomainRequestAdmin(MockEppLib):
readonly_fields = self.admin.get_readonly_fields(request, domain_request)
expected_fields = [
+ "other_contacts",
+ "current_websites",
+ "alternative_domains",
"id",
"created_at",
"updated_at",
@@ -1497,8 +1482,6 @@ class TestDomainRequestAdmin(MockEppLib):
"is_policy_acknowledged",
"submission_date",
"notes",
- "current_websites",
- "other_contacts",
"alternative_domains",
]
@@ -1512,13 +1495,14 @@ class TestDomainRequestAdmin(MockEppLib):
readonly_fields = self.admin.get_readonly_fields(request)
expected_fields = [
+ "other_contacts",
+ "current_websites",
+ "alternative_domains",
"creator",
"about_your_organization",
"requested_domain",
"approved_domain",
"alternative_domains",
- "other_contacts",
- "current_websites",
"purpose",
"submitter",
"no_other_contacts_rationale",
@@ -1535,7 +1519,11 @@ class TestDomainRequestAdmin(MockEppLib):
readonly_fields = self.admin.get_readonly_fields(request)
- expected_fields = []
+ expected_fields = [
+ "other_contacts",
+ "current_websites",
+ "alternative_domains",
+ ]
self.assertEqual(readonly_fields, expected_fields)
@@ -1979,6 +1967,7 @@ class TestDomainInformationAdmin(TestCase):
p = "userpass"
self.client.login(username="staffuser", password=p)
+
response = self.client.get(
"/admin/registrar/domaininformation/{}/change/".format(domain_info.pk),
follow=True,
@@ -2043,12 +2032,10 @@ class TestDomainInformationAdmin(TestCase):
expected_email = "meoward.jones@igorville.gov"
expected_creator_fields = [
# Field, expected value
- ("title", "Treat inspector"),
- ("email", f"{expected_email}"),
- # Check for the existence of the copy button input.
- # Lets keep things simple to minimize future conflicts.
+ ("title", "Treat inspector"),
+ ("email", "meoward.jones@igorville.gov"),
+ ("phone", "(555) 123 12345"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_creator_fields)
@@ -2059,10 +2046,10 @@ class TestDomainInformationAdmin(TestCase):
expected_email = "mayor@igorville.gov"
expected_submitter_fields = [
# Field, expected value
- ("title", "Admin Tester"),
- ("email", f"{expected_email}"),
+ ("title", "Admin Tester"),
+ ("email", "mayor@igorville.gov"),
+ ("phone", "(555) 555 5556"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields)
self.assertContains(response, "Testy2 Tester2")
@@ -2071,43 +2058,28 @@ class TestDomainInformationAdmin(TestCase):
expected_email = "testy@town.com"
expected_ao_fields = [
# Field, expected value
- ("title", "Chief Tester"),
- ("email", "testy@town.com"),
+ ("title", "Chief Tester"),
+ ("email", "testy@town.com"),
+ ("phone", "(555) 555 5555"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields)
- # count=4 because the underlying domain has two users with this name.
+ # count=5 because the underlying domain has two users with this name.
# The dropdown has 3 of these.
- self.assertContains(response, "Testy Tester", count=4)
-
- # Check for table titles. We only need to check for the end tag
- # (Otherwise this test will fail if we change classes, etc)
-
- # Title. Count=3 because this table appears on three records.
- self.assertContains(response, "Title", count=3)
-
- # Email. Count=3 because this table appears on three records.
- self.assertContains(response, "Email", count=3)
-
- # Phone. Count=3 because this table appears on three records.
- self.assertContains(response, "Phone", count=3)
+ self.assertContains(response, "Testy Tester", count=5)
# == Test the other_employees field == #
expected_email = "testy@town.com"
expected_other_employees_fields = [
# Field, expected value
- ("title", "Another Tester"),
- ("email", f"{expected_email}"),
+ ("title", "Another Tester"),
+ ("email", "testy2@town.com"),
+ ("phone", "(555) 555 5557"),
("email_copy_button_input", f'
"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields)
- # count=1 as only one should exist in a table
- self.assertContains(response, "Testy Tester", count=1)
-
def test_readonly_fields_for_analyst(self):
"""Ensures that analysts have their permissions setup correctly"""
with less_console_noise():
@@ -2117,6 +2089,7 @@ class TestDomainInformationAdmin(TestCase):
readonly_fields = self.admin.get_readonly_fields(request)
expected_fields = [
+ "other_contacts",
"creator",
"type_of_work",
"more_organization_information",
@@ -2126,7 +2099,6 @@ class TestDomainInformationAdmin(TestCase):
"no_other_contacts_rationale",
"anything_else",
"is_policy_acknowledged",
- "other_contacts",
]
self.assertEqual(readonly_fields, expected_fields)