diff --git a/src/registrar/admin.py b/src/registrar/admin.py index a3cc0d2d1..ae925b5c3 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -913,6 +913,8 @@ class DomainInformationAdmin(ListHeaderAdmin): # Table ordering ordering = ["domain__name"] + change_form_template = "django/admin/domain_information_change_form.html" + def get_readonly_fields(self, request, obj=None): """Set the read-only state on form elements. We have 1 conditions that determine which fields are read-only: diff --git a/src/registrar/templates/admin/fieldset.html b/src/registrar/templates/admin/fieldset.html index 96433e972..37f79ab46 100644 --- a/src/registrar/templates/admin/fieldset.html +++ b/src/registrar/templates/admin/fieldset.html @@ -16,34 +16,49 @@ https://github.com/django/django/blob/main/django/contrib/admin/templates/admin/ {% endif %} {% endblock fieldset_description %} - {% block fieldset_lines %} - {% for line in fieldset %} -
- {% if line.fields|length == 1 %}{{ line.errors }}{% else %}
{% endif %} - {% for field in line %} -
- {% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %} -
- {% if field.is_checkbox %} - {{ field.field }}{{ field.label_tag }} + {% for line in fieldset %} +
+ {% if line.fields|length == 1 %}{{ line.errors }}{% else %}
{% endif %} + {% for field in line %} +
+ {% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %} +
+ {% if field.is_checkbox %} + {% block field_checkbox %} + {{ field.field }}{{ field.label_tag }} + {% endblock field_checkbox%} + {% else %} + {{ field.label_tag }} + {% if field.is_readonly %} + {% block field_readonly %} +
{{ field.contents }}
+ {% endblock field_readonly%} {% else %} - {{ field.label_tag }} - {% if field.is_readonly %} -
{{ field.contents }}
- {% else %} - {{ field.field }} - {% endif %} + {% block field_other %} + {{ field.field }} + {% endblock field_other%} {% endif %} -
- {% if field.field.help_text %} -
-
{{ field.field.help_text|safe }}
-
- {% endif %} -
- {% endfor %} - {% if not line.fields|length == 1 %}
{% endif %} -
- {% endfor %} - {% endblock fieldset_lines %} + {% endif %} +
+ + {% block before_help_text %} + {# For templating purposes #} + {% endblock before_help_text %} + + {% if field.field.help_text %} + {% block help_text %} +
+
{{ field.field.help_text|safe }}
+
+ {% endblock help_text %} + {% endif %} + + {% block after_help_text %} + {# For templating purposes #} + {% endblock after_help_text %} +
+ {% endfor %} + {% if not line.fields|length == 1 %}
{% endif %} +
+ {% endfor %} diff --git a/src/registrar/templates/django/admin/domain_information_change_form.html b/src/registrar/templates/django/admin/domain_information_change_form.html new file mode 100644 index 000000000..86475890d --- /dev/null +++ b/src/registrar/templates/django/admin/domain_information_change_form.html @@ -0,0 +1,8 @@ +{% extends 'admin/change_form.html' %} +{% load i18n static %} + +{% block field_sets %} + {% for fieldset in adminform %} + {% include "django/admin/includes/domain_information_fieldset.html" %} + {% endfor %} +{% endblock %} diff --git a/src/registrar/templates/django/admin/includes/domain_request_detail_table.html b/src/registrar/templates/django/admin/includes/contact_detail_table.html similarity index 100% rename from src/registrar/templates/django/admin/includes/domain_request_detail_table.html rename to src/registrar/templates/django/admin/includes/contact_detail_table.html diff --git a/src/registrar/templates/django/admin/includes/detail_table_fieldset.html b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html new file mode 100644 index 000000000..f5a5b71ee --- /dev/null +++ b/src/registrar/templates/django/admin/includes/detail_table_fieldset.html @@ -0,0 +1,61 @@ +{% extends "admin/fieldset.html" %} +{% load static url_helpers %} + +{% comment %} +This is using a custom implementation fieldset.html (see admin/fieldset.html) +{% endcomment %} +{% block field_readonly %} + {% if field.field.name == "other_contacts" %} +
+ {% for contact in field.contents|split:", " %} + {{ contact }}{% if not forloop.last %}, {% endif %} + {% endfor %} +
+ {% 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). + + 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 %} + {% else %} +
{{ field.contents }}
+ {% endif %} +{% 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" %} + {% elif field.field.name == "submitter" %} + {% include "django/admin/includes/contact_detail_table.html" with user=original.submitter field_name="submitter" %} + {% elif field.field.name == "authorizing_official" %} + {% include "django/admin/includes/contact_detail_table.html" with user=original.authorizing_official field_name="authorizing_official" %} + {% 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 %} + + + + + + + {% endfor %} + +
{{contact.first_name}} {{contact.last_name}}{{ contact.title }}{{ contact.email }}{{ contact.phone }}
+
+
+ {% 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 new file mode 100644 index 000000000..564415f24 --- /dev/null +++ b/src/registrar/templates/django/admin/includes/domain_information_fieldset.html @@ -0,0 +1,5 @@ +{% extends "django/admin/includes/detail_table_fieldset.html" %} + +{% block after_help_text %} +
TESTING123
+{% endblock after_help_text %} \ No newline at end of file diff --git a/src/registrar/templates/django/admin/includes/domain_request_fieldset.html b/src/registrar/templates/django/admin/includes/domain_request_fieldset.html index f4e68bd0c..c694eb353 100644 --- a/src/registrar/templates/django/admin/includes/domain_request_fieldset.html +++ b/src/registrar/templates/django/admin/includes/domain_request_fieldset.html @@ -1,87 +1 @@ -{% extends "admin/fieldset.html" %} -{% load static url_helpers %} -{% comment %} -This is using a custom implementation fieldset.html (see admin/fieldset.html) -{% endcomment %} -{% block fieldset_lines %} -{% for line in fieldset %} -
- {% if line.fields|length == 1 %}{{ line.errors }}{% else %}
{% endif %} - {% for field in line %} -
- {% if not line.fields|length == 1 and not field.is_readonly %}{{ field.errors }}{% endif %} -
- {% if field.is_checkbox %} - {{ field.field }}{{ field.label_tag }} - {% else %} - {{ field.label_tag }} - {% if field.is_readonly %} - {% if field.field.name == "other_contacts" %} -
- {% for contact in field.contents|split:", " %} - {{ contact }}{% if not forloop.last %}, {% endif %} - {% endfor %} -
- {% 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). - - 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 %} - {% else %} -
{{ field.contents }}
- {% endif %} - {% else %} - {{ field.field }} - {% endif %} - {% endif %} -
- - {% if field.field.help_text %} -
-
{{ field.field.help_text|safe }}
-
- {% endif %} - - {% if field.field.name == "creator" %} - {% include "django/admin/includes/domain_request_detail_table.html" with user=original.creator field_name="creator" %} - {% elif field.field.name == "submitter" %} - {% include "django/admin/includes/domain_request_detail_table.html" with user=original.submitter field_name="submitter" %} - {% elif field.field.name == "authorizing_official" %} - {% include "django/admin/includes/domain_request_detail_table.html" with user=original.authorizing_official field_name="authorizing_official" %} - {% elif field.field.name == "other_contacts" %} -
- 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 %} - - - - - - - {% endfor %} - -
{{contact.first_name}} {{contact.last_name}}{{ contact.title }}{{ contact.email }}{{ contact.phone }}
-
-
- {% endif %} -
- {% endfor %} - {% if not line.fields|length == 1 %}
{% endif %} -
-{% endfor %} - -{% endblock fieldset_lines %} +{% extends "django/admin/includes/detail_table_fieldset.html" %} \ No newline at end of file