mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-22 10:46:06 +02:00
Basics
This commit is contained in:
parent
8f8402ffc5
commit
2ad571354e
4 changed files with 126 additions and 0 deletions
|
@ -1099,6 +1099,8 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
||||||
"about_your_organization",
|
"about_your_organization",
|
||||||
"requested_domain",
|
"requested_domain",
|
||||||
"approved_domain",
|
"approved_domain",
|
||||||
|
"other_contacts",
|
||||||
|
"current_websites",
|
||||||
"alternative_domains",
|
"alternative_domains",
|
||||||
"purpose",
|
"purpose",
|
||||||
"submitter",
|
"submitter",
|
||||||
|
@ -1119,6 +1121,8 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
||||||
# Table ordering
|
# Table ordering
|
||||||
ordering = ["requested_domain__name"]
|
ordering = ["requested_domain__name"]
|
||||||
|
|
||||||
|
change_form_template = "django/admin/domain_request_change_form.html"
|
||||||
|
|
||||||
# Trigger action when a fieldset is changed
|
# Trigger action when a fieldset is changed
|
||||||
def save_model(self, request, obj, form, change):
|
def save_model(self, request, obj, form, change):
|
||||||
"""Custom save_model definition that handles edge cases"""
|
"""Custom save_model definition that handles edge cases"""
|
||||||
|
|
49
src/registrar/templates/admin/fieldset.html
Normal file
49
src/registrar/templates/admin/fieldset.html
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{% load i18n static %}
|
||||||
|
|
||||||
|
{% comment %}
|
||||||
|
This is copied from Djangos implementation of this template, with added "blocks"
|
||||||
|
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
|
||||||
|
{% endcomment %}
|
||||||
|
<fieldset class="module aligned {{ fieldset.classes }}">
|
||||||
|
{% block fieldset_title %}
|
||||||
|
{% if fieldset.name %}<h2>{{ fieldset.name }}</h2>{% endif %}
|
||||||
|
{% endblock fieldset_title %}
|
||||||
|
|
||||||
|
{% block fieldset_description %}
|
||||||
|
{% if fieldset.description %}
|
||||||
|
<div class="description">{{ fieldset.description|safe }}</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock fieldset_description %}
|
||||||
|
|
||||||
|
{% block fieldset_lines %}
|
||||||
|
{% 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 %}">
|
||||||
|
{% 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>
|
||||||
|
{% else %}
|
||||||
|
{{ field.field }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</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 %}
|
||||||
|
</fieldset>
|
|
@ -0,0 +1,8 @@
|
||||||
|
{% extends 'admin/change_form.html' %}
|
||||||
|
{% load i18n static %}
|
||||||
|
|
||||||
|
{% block field_sets %}
|
||||||
|
{% for fieldset in adminform %}
|
||||||
|
{% include "django/admin/includes/domain_request_fieldset.html" %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
|
@ -0,0 +1,65 @@
|
||||||
|
{% extends "admin/fieldset.html" %}
|
||||||
|
|
||||||
|
{% comment %}
|
||||||
|
This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||||
|
{% endcomment %}
|
||||||
|
{% block fieldset_lines %}
|
||||||
|
{% 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 %}">
|
||||||
|
{% 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>
|
||||||
|
{% else %}
|
||||||
|
{{ field.field }}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% if field.field.name == "creator" %}
|
||||||
|
<ul>
|
||||||
|
{% if original.creator.title %}
|
||||||
|
<li>{{ original.creator.title }}</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if original.creator.email %}
|
||||||
|
<li>{{ original.creator.email }}</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if original.creator.phone %}
|
||||||
|
<li>{{ original.creator.phone }}</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% elif field.field.name == "submitter" %}
|
||||||
|
<ul>
|
||||||
|
{% if original.submitter.title %}
|
||||||
|
<li>{{ original.submitter.title }}</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if original.submitter.email %}
|
||||||
|
<li>{{ original.submitter.email }}</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if original.submitter.phone %}
|
||||||
|
<li>{{ original.submitter.phone }}</li>
|
||||||
|
{% endif %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% 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 %}
|
Loading…
Add table
Add a link
Reference in a new issue