Fix tests, cleanup

This commit is contained in:
zandercymatics 2024-03-27 14:57:41 -06:00
parent d9b4d58e55
commit f53a4414ef
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
6 changed files with 74 additions and 102 deletions

View file

@ -175,10 +175,7 @@ function checkToListThenInitWidget(toListId, attempts) {
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
// Select all table rows that have a data-contact-id attribute // Select all table rows that have a data-contact-id attribute
let contactRows = document.querySelectorAll("tr[data-contact-url]"); let contactRows = document.querySelectorAll("tr[data-contact-url]");
console.log(`contact rows at this point: ${contactRows}`)
console.log(`length of ont ${contactRows.length}`)
if (!contactRows || contactRows.length == 0) { if (!contactRows || contactRows.length == 0) {
console.log("in if statement")
contactRows = document.querySelectorAll(".other-contact-id") contactRows = document.querySelectorAll(".other-contact-id")
} }

View file

@ -354,6 +354,13 @@ details.dja-detail-table {
color: var(--body-quiet-color); color: var(--body-quiet-color);
} }
@media (max-width: 1024px){
.dja-detail-contents {
max-width: 400px !important;
overflow-x: scroll !important;
}
}
tr { tr {
background-color: transparent; background-color: transparent;
} }
@ -371,34 +378,18 @@ details.dja-detail-table {
} }
table.dja-user-detail-table { ul {
tr { .padding-left-0__detail-list {
background-color: var(--body-bg); padding-left: 0 !important;
} }
// Make the head of the user detail table "float" .margin-left-0__detail-list {
thead > tr > th { margin-left: 0 !important;
border-radius: 4px;
border-top: none;
border-bottom: none;
} }
th, td { .margin-top-neg-1__detail-list {
border: none margin-top: -8px !important;
} }
}
ul.padding-left-0__detail-list {
padding-left: 0 !important;
}
ul.margin-left-0__detail-list {
margin-left: 0 !important;
}
ul.margin-top-neg-1__detail-list {
margin-top: -8px !important;
} }
.dja-detail-list { .dja-detail-list {

View file

@ -6,17 +6,11 @@ It is not inherently customizable on its own, so we can modify this instead.
https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/includes/fieldset.html https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/includes/fieldset.html
{% endcomment %} {% endcomment %}
<fieldset class="module aligned {{ fieldset.classes }}"> <fieldset class="module aligned {{ fieldset.classes }}">
{# .gov override #} {% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% block fieldset_title %}
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
{% endblock fieldset_title %}
{# .gov override #} {% if fieldset.description %}
{% block fieldset_description %} <div class="description">{{ fieldset.description|safe }}</div>
{% if fieldset.description %} {% endif %}
<div class="description">{{ fieldset.description|safe }}</div>
{% endif %}
{% endblock fieldset_description %}
{% for line in fieldset %} {% for line in fieldset %}
<div class="form-row{% if line.fields|length == 1 and line.errors %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}"> <div class="form-row{% if line.fields|length == 1 and line.errors %} errors{% endif %}{% if not line.has_visible_field %} hidden{% endif %}{% for field in line %}{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% endfor %}">
@ -45,11 +39,6 @@ https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>
{# .gov addition #}
{% block before_help_text %}
{# For templating purposes #}
{% endblock before_help_text %}
{% if field.field.help_text %} {% if field.field.help_text %}
{# .gov override #} {# .gov override #}

View file

@ -4,41 +4,36 @@
<ul class="{% if no_title_top_padding %}margin-top-neg-1__detail-list{% endif %} padding-top-0 padding-left-0__detail-list margin-left-0__detail-list" {% if field_name %} id="id_detail_list__{{field_name}}" {% endif %}> <ul class="{% if no_title_top_padding %}margin-top-neg-1__detail-list{% endif %} padding-top-0 padding-left-0__detail-list margin-left-0__detail-list" {% if field_name %} id="id_detail_list__{{field_name}}" {% endif %}>
{% if user.title or user.contact.title or user.email or user.contact.email or user.phone or user.contact.phone %} {% if user.title or user.contact.title or user.email or user.contact.email or user.phone or user.contact.phone %}
{# Title #} {# Title #}
<li> {% if user.title or user.contact.title %}
{% if user.title or user.contact.title %} {% if user.contact.title %}
{% if user.contact.title %} <li>{{ user.contact.title }}</li>
{{ user.contact.title }}
{% else %}
{{ user.title }}
{% endif %}
{% else %} {% else %}
None <li>{{ user.title }}</li>
{% endif %} {% endif %}
</li> {% else %}
<li>None</li>
{% endif %}
{# Email #} {# Email #}
<li> {% if user.email or user.contact.email %}
{% if user.email or user.contact.email %} {% if user.contact.email %}
{% if user.contact.email %} <li>{{ user.contact.email }}</li>
{{ user.contact.email }}
{% else %}
{{ user.email }}
{% endif %}
{% else %} {% else %}
None <li>{{ user.email }}</li>
{% endif %} {% endif %}
</li> {% else %}
<li>None</li>
{% endif %}
{# Phone #} {# Phone #}
<li> {% if user.phone or user.contact.phone %}
{% if user.phone or user.contact.phone %} {% if user.contact.phone %}</li>
{% if user.contact.phone %} <li>{{ user.contact.phone }}</li>
{{ user.contact.phone.as_national }}
{% else %}
{{ user.phone.as_national }}
{% endif %}
{% else %} {% else %}
None <li>{{ user.phone }}</li>
{% endif %} {% endif %}
</li> {% else %}
<li>None</li>
{% endif %}
{% else %} {% else %}
<li> <li>
No additional contact information found. No additional contact information found.

View file

@ -22,10 +22,10 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
</dt> </dt>
<dd> <dd>
<address> <address>
{% if contact.get_formatted_name %}<a href="{% url 'admin:registrar_contact_change' contact.id %}">{{ contact.get_formatted_name }}</a><br />{% else %}None<br />{% endif %} {% if contact.get_formatted_name %}<a href="{% url 'admin:registrar_contact_change' contact.id %}">{{ contact.get_formatted_name }}</a><br />{% else %}None<br />{% endif %}
{% if contact.title %}{{ contact.title }}<br />{% else %}None<br />{% endif %} {% if contact.title %}{{ contact.title }}<br />{% else %}None<br />{% endif %}
{% if contact.email %}{{ contact.email }}<br />{% else %}None<br />{% endif %} {% if contact.email %}{{ contact.email }}<br />{% else %}None<br />{% endif %}
{% if contact.phone %}{{ contact.phone.as_national }}{% else %}None{% endif %} {% if contact.phone %}{{ contact.phone }}{% else %}None{% endif %}
</address> </address>
</dd> </dd>
{% endfor %} {% endfor %}

View file

@ -1307,9 +1307,9 @@ class TestDomainRequestAdmin(MockEppLib):
# (Otherwise this test will fail if we change classes, etc) # (Otherwise this test will fail if we change classes, etc)
expected_creator_fields = [ expected_creator_fields = [
# Field, expected value # Field, expected value
("title", "Treat inspector</td>"), ("title", "Treat inspector</li>"),
("email", "meoward.jones@igorville.gov</td>"), ("email", "meoward.jones@igorville.gov</li>"),
("phone", "(555) 123 12345</td>"), ("phone", "(555) 123 12345</li>"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_creator_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_creator_fields)
@ -1319,9 +1319,9 @@ class TestDomainRequestAdmin(MockEppLib):
# == Check for the submitter == # # == Check for the submitter == #
expected_submitter_fields = [ expected_submitter_fields = [
# Field, expected value # Field, expected value
("title", "Admin Tester</td>"), ("title", "Admin Tester</li>"),
("email", "mayor@igorville.gov</td>"), ("email", "mayor@igorville.gov</li>"),
("phone", "(555) 555 5556</td>"), ("phone", "(555) 555 5556</li>"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields)
self.assertContains(response, "Testy2 Tester2") self.assertContains(response, "Testy2 Tester2")
@ -1329,22 +1329,22 @@ class TestDomainRequestAdmin(MockEppLib):
# == Check for the authorizing_official == # # == Check for the authorizing_official == #
expected_ao_fields = [ expected_ao_fields = [
# Field, expected value # Field, expected value
("title", "Chief Tester</td>"), ("title", "Chief Tester</li>"),
("email", "testy@town.com</td>"), ("email", "testy@town.com</li>"),
("phone", "(555) 555 5555</td>"), ("phone", "(555) 555 5555</li>"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields)
# count=5 because the underlying domain has two users with this name. # count=3 because the underlying domain has two users with this name.
# The dropdown has 4 of these. # The dropdown has 2 of these.
self.assertContains(response, "Testy Tester", count=5) self.assertContains(response, "Testy Tester", count=3)
# == Test the other_employees field == # # == Test the other_employees field == #
expected_other_employees_fields = [ expected_other_employees_fields = [
# Field, expected value # Field, expected value
("title", "Another Tester</td>"), ("title", "Another Tester"),
("email", "testy2@town.com</td>"), ("email", "testy2@town.com"),
("phone", "(555) 555 5557</td>"), ("phone", "(555) 555 5557"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields)
@ -2022,9 +2022,9 @@ class TestDomainInformationAdmin(TestCase):
# (Otherwise this test will fail if we change classes, etc) # (Otherwise this test will fail if we change classes, etc)
expected_creator_fields = [ expected_creator_fields = [
# Field, expected value # Field, expected value
("title", "Treat inspector</td>"), ("title", "Treat inspector</li>"),
("email", "meoward.jones@igorville.gov</td>"), ("email", "meoward.jones@igorville.gov</li>"),
("phone", "(555) 123 12345</td>"), ("phone", "(555) 123 12345</li>"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_creator_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_creator_fields)
@ -2034,9 +2034,9 @@ class TestDomainInformationAdmin(TestCase):
# == Check for the submitter == # # == Check for the submitter == #
expected_submitter_fields = [ expected_submitter_fields = [
# Field, expected value # Field, expected value
("title", "Admin Tester</td>"), ("title", "Admin Tester</li>"),
("email", "mayor@igorville.gov</td>"), ("email", "mayor@igorville.gov</li>"),
("phone", "(555) 555 5556</td>"), ("phone", "(555) 555 5556</li>"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields)
self.assertContains(response, "Testy2 Tester2") self.assertContains(response, "Testy2 Tester2")
@ -2044,22 +2044,22 @@ class TestDomainInformationAdmin(TestCase):
# == Check for the authorizing_official == # # == Check for the authorizing_official == #
expected_ao_fields = [ expected_ao_fields = [
# Field, expected value # Field, expected value
("title", "Chief Tester</td>"), ("title", "Chief Tester</li>"),
("email", "testy@town.com</td>"), ("email", "testy@town.com</li>"),
("phone", "(555) 555 5555</td>"), ("phone", "(555) 555 5555</li>"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields)
# count=5 because the underlying domain has two users with this name. # count=3 because the underlying domain has two users with this name.
# The dropdown has 4 of these. # The dropdown has 2 of these.
self.assertContains(response, "Testy Tester", count=5) self.assertContains(response, "Testy Tester", count=3)
# == Test the other_employees field == # # == Test the other_employees field == #
expected_other_employees_fields = [ expected_other_employees_fields = [
# Field, expected value # Field, expected value
("title", "Another Tester</td>"), ("title", "Another Tester"),
("email", "testy2@town.com</td>"), ("email", "testy2@town.com"),
("phone", "(555) 555 5557</td>"), ("phone", "(555) 555 5557"),
] ]
self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields) self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields)