mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 19:09:22 +02:00
Add inline
This commit is contained in:
parent
990a6f51e8
commit
1bcc57e51e
6 changed files with 20 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
|||
from datetime import date
|
||||
import logging
|
||||
import copy
|
||||
|
||||
from django.forms.models import BaseInlineFormSet
|
||||
from django import forms
|
||||
from django.db.models import Value, CharField, Q
|
||||
from django.db.models.functions import Concat, Coalesce
|
||||
|
@ -69,7 +69,6 @@ class DomainInformationInlineForm(forms.ModelForm):
|
|||
widgets = {
|
||||
"other_contacts": NoAutocompleteFilteredSelectMultiple("other_contacts", False),
|
||||
}
|
||||
template = "django/admin/domain_information_change_form.html"
|
||||
|
||||
|
||||
class DomainRequestAdminForm(forms.ModelForm):
|
||||
|
@ -1442,7 +1441,6 @@ class DomainInformationInline(admin.StackedInline):
|
|||
|
||||
form = DomainInformationInlineForm
|
||||
model = models.DomainInformation
|
||||
template = "django/admin/domain_information_inline_change_form.html"
|
||||
|
||||
fieldsets = copy.deepcopy(DomainInformationAdmin.fieldsets)
|
||||
# remove .gov domain from fieldset
|
||||
|
@ -1450,7 +1448,8 @@ class DomainInformationInline(admin.StackedInline):
|
|||
if title == ".gov domain":
|
||||
del fieldsets[index]
|
||||
break
|
||||
|
||||
|
||||
readonly_fields = DomainInformationAdmin.readonly_fields
|
||||
analyst_readonly_fields = DomainInformationAdmin.analyst_readonly_fields
|
||||
# For each filter_horizontal, init in admin js extendFilterHorizontalWidgets
|
||||
# to activate the edit/delete/view buttons
|
||||
|
@ -1616,7 +1615,7 @@ class DomainAdmin(ListHeaderAdmin):
|
|||
"""Custom changeform implementation to pass in context information"""
|
||||
if extra_context is None:
|
||||
extra_context = {}
|
||||
|
||||
extra_context["original_object"] = self.model.objects.get(pk=object_id)
|
||||
# Pass in what the an extended expiration date would be for the expiration date modal
|
||||
if object_id is not None:
|
||||
domain = Domain.objects.get(pk=object_id)
|
||||
|
|
|
@ -36,6 +36,12 @@
|
|||
{{ block.super }}
|
||||
{% endblock %}
|
||||
|
||||
{% block inline_field_sets %}
|
||||
{% for inline_admin_formset in inline_admin_formsets %}
|
||||
{% include "django/admin/includes/domain_information_inline_change_form.html" with original_object=original.domain_info%}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block submit_buttons_bottom %}
|
||||
{% comment %}
|
||||
Modals behave very weirdly in django admin.
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
Use detail_table_fieldset as an example, or just extend it.
|
||||
{% endcomment %}
|
||||
{% include "django/admin/includes/detail_table_fieldset.html" %}
|
||||
{% include "django/admin/includes/detail_table_fieldset.html" with original_object=original %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
Use detail_table_fieldset as an example, or just extend it.
|
||||
{% endcomment %}
|
||||
{% include "django/admin/includes/detail_table_fieldset.html" %}
|
||||
{% include "django/admin/includes/detail_table_fieldset.html" with original_object=original %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
||||
{% endcomment %}
|
||||
{% block field_readonly %}
|
||||
{% with all_contacts=original.other_contacts.all %}
|
||||
{% with all_contacts=original_object.other_contacts.all %}
|
||||
{% if field.field.name == "other_contacts" %}
|
||||
{% if all_contacts.count > 2 %}
|
||||
<div class="readonly">
|
||||
|
@ -49,7 +49,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
|||
</div>
|
||||
{% elif field.field.name == "alternative_domains" %}
|
||||
<div class="readonly">
|
||||
{% for alt_domain in original.alternative_domains.all %}
|
||||
{% for alt_domain in original_object.alternative_domains.all %}
|
||||
<a href="{% url 'admin:registrar_website_change' alt_domain.id %}">{{ alt_domain }}</a>{% if not forloop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
@ -63,20 +63,20 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
|||
{% if field.field.name == "creator" %}
|
||||
<div class="flex-container">
|
||||
<label aria-label="Creator contact details"></label>
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original.creator no_title_top_padding=field.is_readonly %}
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original_object.creator no_title_top_padding=field.is_readonly %}
|
||||
</div>
|
||||
{% elif field.field.name == "submitter" %}
|
||||
<div class="flex-container">
|
||||
<label aria-label="Submitter contact details"></label>
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original.submitter no_title_top_padding=field.is_readonly %}
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original_object.submitter no_title_top_padding=field.is_readonly %}
|
||||
</div>
|
||||
{% elif field.field.name == "authorizing_official" %}
|
||||
<div class="flex-container">
|
||||
<label aria-label="Authorizing official contact details"></label>
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original.authorizing_official no_title_top_padding=field.is_readonly %}
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original_object.authorizing_official no_title_top_padding=field.is_readonly %}
|
||||
</div>
|
||||
{% elif field.field.name == "other_contacts" and original.other_contacts.all %}
|
||||
{% with all_contacts=original.other_contacts.all %}
|
||||
{% elif field.field.name == "other_contacts" and original_object.other_contacts.all %}
|
||||
{% with all_contacts=original_object.other_contacts.all %}
|
||||
{% if all_contacts.count > 2 %}
|
||||
<details class="margin-top-1 dja-detail-table" aria-role="button" open>
|
||||
<summary class="padding-1 padding-left-0 dja-details-summary">Details</summary>
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
{% load i18n static %}
|
||||
|
||||
{% block fieldset %}
|
||||
{% include "django/admin/includes/detail_table_fieldset.html" %}
|
||||
{% include "django/admin/includes/detail_table_fieldset.html" with original_object=original_object %}
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue