diff --git a/src/registrar/admin.py b/src/registrar/admin.py index a06588c9e..264257b35 100644 --- a/src/registrar/admin.py +++ b/src/registrar/admin.py @@ -1438,15 +1438,10 @@ class DomainInformationInline(admin.StackedInline): and the source DomainInformationAdmin since these classes conflict, so we'll just pull what we need from DomainInformationAdmin - - Note that `template` cannot be set through this function, - due to how admin.StackedInline behaves. - - See `domain_change_form.html` for more information. """ form = DomainInformationInlineForm - + template = "django/admin/includes/domain_info_inline_stacked.html" model = models.DomainInformation fieldsets = copy.deepcopy(DomainInformationAdmin.fieldsets) @@ -1623,11 +1618,14 @@ class DomainAdmin(ListHeaderAdmin): if extra_context is None: extra_context = {} - # 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) - years_to_extend_by = self._get_calculated_years_for_exp_date(domain) + # Use in the custom contact view + extra_context["original_object"] = domain.domain_info + + # Pass in what the an extended expiration date would be for the expiration date modal + years_to_extend_by = self._get_calculated_years_for_exp_date(domain) try: curr_exp_date = domain.registry_expiration_date except KeyError: diff --git a/src/registrar/templates/django/admin/domain_change_form.html b/src/registrar/templates/django/admin/domain_change_form.html index d1767facd..44fe6851b 100644 --- a/src/registrar/templates/django/admin/domain_change_form.html +++ b/src/registrar/templates/django/admin/domain_change_form.html @@ -36,26 +36,6 @@ {{ block.super }} {% endblock %} -{% comment %} -The custom inline definition MUST be passed in this way. -This is because we can't pass in additional context information from this scope -unless by overriding a bunch of base formset functions. -In this version of Django, inlines are handled much differently on the backend when there isn't a clear -reason as to why. It appears to be that they simply haven't been updated for a while. - -Alternatively, we could create a second "duplicate" detail_table_fieldset.html file (or many if statements), -but we lose out on centralizing all this logic inside of one file. The tradeoff here seems to be between -code duplication vs not overriding the default. - -As a consequence, this means that we can't override the template on this inline by -passing in template="path/to/file". We get much more control this way. -{% endcomment %} -{% block inline_field_sets %} - {% for inline_admin_formset in inline_admin_formsets %} - {% include "django/admin/includes/domain_info_inline_stacked.html" with original_object=original.domain_info%} - {% endfor %} -{% endblock %} - {% block submit_buttons_bottom %} {% comment %} Modals behave very weirdly in django admin.