mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-20 03:19:24 +02:00
Simplify how template is dealt with
This commit is contained in:
parent
d33742cfc8
commit
c4b772df6e
2 changed files with 6 additions and 28 deletions
|
@ -1438,15 +1438,10 @@ class DomainInformationInline(admin.StackedInline):
|
||||||
and the source DomainInformationAdmin since these
|
and the source DomainInformationAdmin since these
|
||||||
classes conflict, so we'll just pull what we need
|
classes conflict, so we'll just pull what we need
|
||||||
from DomainInformationAdmin
|
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
|
form = DomainInformationInlineForm
|
||||||
|
template = "django/admin/includes/domain_info_inline_stacked.html"
|
||||||
model = models.DomainInformation
|
model = models.DomainInformation
|
||||||
|
|
||||||
fieldsets = copy.deepcopy(DomainInformationAdmin.fieldsets)
|
fieldsets = copy.deepcopy(DomainInformationAdmin.fieldsets)
|
||||||
|
@ -1623,11 +1618,14 @@ class DomainAdmin(ListHeaderAdmin):
|
||||||
if extra_context is None:
|
if extra_context is None:
|
||||||
extra_context = {}
|
extra_context = {}
|
||||||
|
|
||||||
# Pass in what the an extended expiration date would be for the expiration date modal
|
|
||||||
if object_id is not None:
|
if object_id is not None:
|
||||||
domain = Domain.objects.get(pk=object_id)
|
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:
|
try:
|
||||||
curr_exp_date = domain.registry_expiration_date
|
curr_exp_date = domain.registry_expiration_date
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
|
@ -36,26 +36,6 @@
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
{% endblock %}
|
{% 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 %}
|
{% block submit_buttons_bottom %}
|
||||||
{% comment %}
|
{% comment %}
|
||||||
Modals behave very weirdly in django admin.
|
Modals behave very weirdly in django admin.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue