mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-21 03:49:22 +02:00
some incremental changes
This commit is contained in:
parent
ecafaa58c9
commit
1ebff9fc45
3 changed files with 84 additions and 7 deletions
|
@ -2272,6 +2272,17 @@ class DomainInformationInline(admin.StackedInline):
|
||||||
analyst_readonly_fields = DomainInformationAdmin.analyst_readonly_fields
|
analyst_readonly_fields = DomainInformationAdmin.analyst_readonly_fields
|
||||||
autocomplete_fields = DomainInformationAdmin.autocomplete_fields
|
autocomplete_fields = DomainInformationAdmin.autocomplete_fields
|
||||||
|
|
||||||
|
# Removing specific fields from the first fieldset dynamically
|
||||||
|
fieldsets[0][1]["fields"] = [
|
||||||
|
field for field in fieldsets[0][1]["fields"] if field not in ["creator", "submitter", "domain_request", "notes"]
|
||||||
|
]
|
||||||
|
fieldsets[2][1]["fields"] = [
|
||||||
|
field for field in fieldsets[2][1]["fields"] if field not in ["other_contacts", "no_other_contacts_rationale"]
|
||||||
|
]
|
||||||
|
fieldsets[3][1]["fields"].extend(["other_contacts", "no_other_contacts_rationale"]) # type: ignore
|
||||||
|
fieldsets_to_move = fieldsets.pop(3)
|
||||||
|
fieldsets.append(fieldsets_to_move)
|
||||||
|
|
||||||
def has_change_permission(self, request, obj=None):
|
def has_change_permission(self, request, obj=None):
|
||||||
"""Custom has_change_permission override so that we can specify that
|
"""Custom has_change_permission override so that we can specify that
|
||||||
analysts can edit this through this inline, but not through the model normally"""
|
analysts can edit this through this inline, but not through the model normally"""
|
||||||
|
@ -2382,14 +2393,11 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
fieldsets = (
|
fieldsets = (
|
||||||
(
|
(
|
||||||
None,
|
"Domain Information",
|
||||||
{"fields": ["name", "state", "expiration_date", "first_ready", "deleted"]},
|
{"fields": ["state", "expiration_date", "first_ready", "deleted", "dnssecdata", "nameservers"]},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# this ordering effects the ordering of results in autocomplete_fields for domain
|
|
||||||
ordering = ["name"]
|
|
||||||
|
|
||||||
def generic_org_type(self, obj):
|
def generic_org_type(self, obj):
|
||||||
return obj.domain_info.get_generic_org_type_display()
|
return obj.domain_info.get_generic_org_type_display()
|
||||||
|
|
||||||
|
@ -2410,6 +2418,25 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
organization_name.admin_order_field = "domain_info__organization_name" # type: ignore
|
organization_name.admin_order_field = "domain_info__organization_name" # type: ignore
|
||||||
|
|
||||||
|
def dnssecdata(self, obj):
|
||||||
|
return "Yes" if obj.dnssecdata else "No"
|
||||||
|
|
||||||
|
dnssecdata.short_description = "DNS Sec Enabled" # type: ignore
|
||||||
|
|
||||||
|
# Custom method to display formatted nameservers
|
||||||
|
def nameservers(self, obj):
|
||||||
|
if not obj.nameservers:
|
||||||
|
return "No nameservers"
|
||||||
|
|
||||||
|
formatted_nameservers = []
|
||||||
|
for server, ip_list in obj.nameservers:
|
||||||
|
formatted_nameservers.append(f"{server} [{', '.join(ip_list)}]")
|
||||||
|
|
||||||
|
# Join the formatted strings with line breaks
|
||||||
|
return "\n".join(formatted_nameservers)
|
||||||
|
|
||||||
|
nameservers.short_description = "Nameservers" # type: ignore
|
||||||
|
|
||||||
def custom_election_board(self, obj):
|
def custom_election_board(self, obj):
|
||||||
domain_info = getattr(obj, "domain_info", None)
|
domain_info = getattr(obj, "domain_info", None)
|
||||||
if domain_info:
|
if domain_info:
|
||||||
|
@ -2436,7 +2463,15 @@ class DomainAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
search_fields = ["name"]
|
search_fields = ["name"]
|
||||||
search_help_text = "Search by domain name."
|
search_help_text = "Search by domain name."
|
||||||
change_form_template = "django/admin/domain_change_form.html"
|
change_form_template = "django/admin/domain_change_form.html"
|
||||||
readonly_fields = ("state", "expiration_date", "first_ready", "deleted", "federal_agency")
|
readonly_fields = (
|
||||||
|
"state",
|
||||||
|
"expiration_date",
|
||||||
|
"first_ready",
|
||||||
|
"deleted",
|
||||||
|
"federal_agency",
|
||||||
|
"dnssecdata",
|
||||||
|
"nameservers",
|
||||||
|
)
|
||||||
|
|
||||||
# Table ordering
|
# Table ordering
|
||||||
ordering = ["name"]
|
ordering = ["name"]
|
||||||
|
|
42
src/registrar/templates/admin/stacked_no_heading.html
Normal file
42
src/registrar/templates/admin/stacked_no_heading.html
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
{% load i18n admin_urls %}
|
||||||
|
{% 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/edit_inline/stacked.html
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
|
<div class="js-inline-admin-formset inline-group"
|
||||||
|
id="{{ inline_admin_formset.formset.prefix }}-group"
|
||||||
|
data-inline-type="stacked"
|
||||||
|
data-inline-formset="{{ inline_admin_formset.inline_formset_data }}">
|
||||||
|
|
||||||
|
<fieldset class="module {{ inline_admin_formset.classes }}">
|
||||||
|
{{ inline_admin_formset.formset.management_form }}
|
||||||
|
{{ inline_admin_formset.formset.non_form_errors }}
|
||||||
|
|
||||||
|
{% for inline_admin_form in inline_admin_formset %}<div class="inline-related{% if inline_admin_form.original or inline_admin_form.show_url %} has_original{% endif %}{% if forloop.last and inline_admin_formset.has_add_permission %} empty-form last-related{% endif %}" id="{{ inline_admin_formset.formset.prefix }}-{% if forloop.last and inline_admin_formset.has_add_permission %}empty{% else %}{{ forloop.counter0 }}{% endif %}">
|
||||||
|
{% if inline_admin_form.form.non_field_errors %}
|
||||||
|
{{ inline_admin_form.form.non_field_errors }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for fieldset in inline_admin_form %}
|
||||||
|
{# .gov override #}
|
||||||
|
{% block fieldset %}
|
||||||
|
{% include "admin/includes/fieldset.html" %}
|
||||||
|
{% endblock fieldset%}
|
||||||
|
{# End of .gov override #}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if inline_admin_form.needs_explicit_pk_field %}
|
||||||
|
{{ inline_admin_form.pk_field.field }}
|
||||||
|
{% endif %}
|
||||||
|
{% if inline_admin_form.fk_field %}
|
||||||
|
{{ inline_admin_form.fk_field.field }}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
</div>
|
|
@ -1,4 +1,4 @@
|
||||||
{% extends 'admin/stacked.html' %}
|
{% extends 'admin/stacked_no_heading.html' %}
|
||||||
{% load i18n static %}
|
{% load i18n static %}
|
||||||
|
|
||||||
{% block fieldset %}
|
{% block fieldset %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue