mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-14 16:47:02 +02:00
Add additional copy buttons
This commit is contained in:
parent
54072a479e
commit
be07a06a15
4 changed files with 26 additions and 38 deletions
|
@ -536,6 +536,8 @@ class MyUserAdmin(BaseUserAdmin):
|
||||||
# in autocomplete_fields for user
|
# in autocomplete_fields for user
|
||||||
ordering = ["first_name", "last_name", "email"]
|
ordering = ["first_name", "last_name", "email"]
|
||||||
|
|
||||||
|
change_form_template = "django/admin/email_clipboard_change_form.html"
|
||||||
|
|
||||||
def get_search_results(self, request, queryset, search_term):
|
def get_search_results(self, request, queryset, search_term):
|
||||||
"""
|
"""
|
||||||
Override for get_search_results. This affects any upstream model using autocomplete_fields,
|
Override for get_search_results. This affects any upstream model using autocomplete_fields,
|
||||||
|
@ -1808,6 +1810,8 @@ class VerifiedByStaffAdmin(ListHeaderAdmin):
|
||||||
"requestor",
|
"requestor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
change_form_template = "django/admin/email_clipboard_change_form.html"
|
||||||
|
|
||||||
def truncated_notes(self, obj):
|
def truncated_notes(self, obj):
|
||||||
# Truncate the 'notes' field to 50 characters
|
# Truncate the 'notes' field to 50 characters
|
||||||
return str(obj.notes)[:50]
|
return str(obj.notes)[:50]
|
||||||
|
|
|
@ -1,38 +1,13 @@
|
||||||
{% extends "admin/fieldset.html" %}
|
{% extends "django/admin/includes/detail_table_fieldset.html" %}
|
||||||
|
|
||||||
{% comment %}
|
{% comment %}
|
||||||
This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
{% block fieldset_lines %}
|
|
||||||
{% for line in fieldset %}
|
{% block field_other %}
|
||||||
<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 %}">
|
{% if field.field.name == "email" %}
|
||||||
{% if line.fields|length == 1 %}{{ line.errors }}{% else %}<div class="flex-container form-multiline">{% endif %}
|
|
||||||
{% for field in line %}
|
|
||||||
<div>
|
|
||||||
{% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %}
|
|
||||||
<div class="flex-container{% if not line.fields|length == 1 %} fieldBox{% if field.field.name %} field-{{ field.field.name }}{% endif %}{% if not field.is_readonly and field.errors %} errors{% endif %}{% if field.field.is_hidden %} hidden{% endif %}{% elif field.is_checkbox %} checkbox-row{% endif %}">
|
|
||||||
{% if field.is_checkbox %}
|
|
||||||
{{ field.field }}{{ field.label_tag }}
|
|
||||||
{% else %}
|
|
||||||
{{ field.label_tag }}
|
|
||||||
{% if field.is_readonly %}
|
|
||||||
<div class="readonly">{{ field.contents }}</div>
|
|
||||||
{% elif field.field.name == "email" %}
|
|
||||||
{% include "admin/input_with_clipboard.html" with field=field.field %}
|
{% include "admin/input_with_clipboard.html" with field=field.field %}
|
||||||
{% else %}
|
{% else %}
|
||||||
{{ field.field }}
|
{{ block.super }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endblock field_other %}
|
||||||
</div>
|
|
||||||
{% if field.field.help_text %}
|
|
||||||
<div class="help"{% if field.field.id_for_label %} id="{{ field.field.id_for_label }}_helptext"{% endif %}>
|
|
||||||
<div>{{ field.field.help_text|safe }}</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
{% if not line.fields|length == 1 %}</div>{% endif %}
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
|
|
||||||
{% endblock fieldset_lines %}
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ class GenericTestHelper(TestCase):
|
||||||
Example Usage:
|
Example Usage:
|
||||||
```
|
```
|
||||||
self.assert_sort_helper(
|
self.assert_sort_helper(
|
||||||
self.factory, self.superuser, self.admin, self.url, DomainInformation, "1", ("domain__name",)
|
"1", ("domain__name",)
|
||||||
)
|
)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -204,7 +204,6 @@ class GenericTestHelper(TestCase):
|
||||||
{"action": "delete_selected", "select_across": selected_across, "index": index, "_selected_action": "23"},
|
{"action": "delete_selected", "select_across": selected_across, "index": index, "_selected_action": "23"},
|
||||||
follow=True,
|
follow=True,
|
||||||
)
|
)
|
||||||
print(f"what is the response? {response}")
|
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2022,10 +2022,14 @@ class TestDomainInformationAdmin(TestCase):
|
||||||
# Check for the right title, email, and phone number in the response.
|
# Check for the right title, email, and phone number in the response.
|
||||||
# We only need to check for the end tag
|
# We only need to check for the end tag
|
||||||
# (Otherwise this test will fail if we change classes, etc)
|
# (Otherwise this test will fail if we change classes, etc)
|
||||||
|
expected_email = "meoward.jones@igorville.gov"
|
||||||
expected_creator_fields = [
|
expected_creator_fields = [
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Treat inspector</td>"),
|
("title", "Treat inspector</td>"),
|
||||||
("email", "meoward.jones@igorville.gov</td>"),
|
("email", f"{expected_email}</td>"),
|
||||||
|
# Check for the existence of the copy button input.
|
||||||
|
# Lets keep things simple to minimize future conflicts.
|
||||||
|
("email_copy_button_input", f'<input class="dja-clipboard-input" type="hidden" value="{expected_email}"'),
|
||||||
("phone", "(555) 123 12345</td>"),
|
("phone", "(555) 123 12345</td>"),
|
||||||
]
|
]
|
||||||
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,20 +2038,24 @@ class TestDomainInformationAdmin(TestCase):
|
||||||
self.assertContains(response, "Meoward Jones")
|
self.assertContains(response, "Meoward Jones")
|
||||||
|
|
||||||
# == Check for the submitter == #
|
# == Check for the submitter == #
|
||||||
|
expected_email = "mayor@igorville.gov"
|
||||||
expected_submitter_fields = [
|
expected_submitter_fields = [
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Admin Tester</td>"),
|
("title", "Admin Tester</td>"),
|
||||||
("email", "mayor@igorville.gov</td>"),
|
("email", f"{expected_email}</td>"),
|
||||||
|
("email_copy_button_input", f'<input class="dja-clipboard-input" type="hidden" value="{expected_email}"'),
|
||||||
("phone", "(555) 555 5556</td>"),
|
("phone", "(555) 555 5556</td>"),
|
||||||
]
|
]
|
||||||
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")
|
||||||
|
|
||||||
# == Check for the authorizing_official == #
|
# == Check for the authorizing_official == #
|
||||||
|
expected_email = "testy@town.com"
|
||||||
expected_ao_fields = [
|
expected_ao_fields = [
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Chief Tester</td>"),
|
("title", "Chief Tester</td>"),
|
||||||
("email", "testy@town.com</td>"),
|
("email", "testy@town.com</td>"),
|
||||||
|
("email_copy_button_input", f'<input class="dja-clipboard-input" type="hidden" value="{expected_email}"'),
|
||||||
("phone", "(555) 555 5555</td>"),
|
("phone", "(555) 555 5555</td>"),
|
||||||
]
|
]
|
||||||
self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields)
|
self.test_helper.assert_response_contains_distinct_values(response, expected_ao_fields)
|
||||||
|
@ -2069,10 +2077,12 @@ class TestDomainInformationAdmin(TestCase):
|
||||||
self.assertContains(response, "Phone</th>", count=3)
|
self.assertContains(response, "Phone</th>", count=3)
|
||||||
|
|
||||||
# == Test the other_employees field == #
|
# == Test the other_employees field == #
|
||||||
|
expected_email = "testy@town.com"
|
||||||
expected_other_employees_fields = [
|
expected_other_employees_fields = [
|
||||||
# Field, expected value
|
# Field, expected value
|
||||||
("title", "Another Tester</td>"),
|
("title", "Another Tester</td>"),
|
||||||
("email", "testy2@town.com</td>"),
|
("email", f"{expected_email}</td>"),
|
||||||
|
("email_copy_button_input", f'<input class="dja-clipboard-input" type="hidden" value="{expected_email}"'),
|
||||||
("phone", "(555) 555 5557</td>"),
|
("phone", "(555) 555 5557</td>"),
|
||||||
]
|
]
|
||||||
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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue