mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 06:56:33 +02:00
add new fields to admin and refactor a bit
This commit is contained in:
parent
4c089ff904
commit
61c32351dd
5 changed files with 104 additions and 22 deletions
|
@ -2535,6 +2535,40 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
|
|
||||||
portfolio_urbanization.short_description = "Urbanization" # type: ignore
|
portfolio_urbanization.short_description = "Urbanization" # type: ignore
|
||||||
|
|
||||||
|
# ------ FEB fields ------
|
||||||
|
def feb_naming_requirements_details(self, obj):
|
||||||
|
return obj.feb_naming_requirements_details if obj.feb_naming_requirements else ""
|
||||||
|
|
||||||
|
feb_naming_requirements_details.short_description = "Domain Name Rationale:" # type: ignore
|
||||||
|
|
||||||
|
def feb_purpose_choice(self, obj):
|
||||||
|
return obj.feb_purpose_choice if obj.feb_purpose_choice else ""
|
||||||
|
|
||||||
|
feb_purpose_choice.short_description = "Purpose type:" # type: ignore
|
||||||
|
|
||||||
|
def time_frame_details(self, obj):
|
||||||
|
return obj.time_frame_details if obj.has_timeframe else ""
|
||||||
|
|
||||||
|
time_frame_details.short_description = "Target time frame:" # type: ignore
|
||||||
|
|
||||||
|
def interagency_initiative_details(self, obj):
|
||||||
|
return obj.interagency_initiative_details if obj.is_interagency_initiative else ""
|
||||||
|
|
||||||
|
interagency_initiative_details.short_description = "Interagency Initiative:" # type: ignore
|
||||||
|
|
||||||
|
def eop_stakeholder_first_name(self, obj):
|
||||||
|
return obj.eop_stakeholder_first_name if obj.eop_stakeholder_first_name else ""
|
||||||
|
|
||||||
|
def eop_stakeholder_last_name(self, obj):
|
||||||
|
return obj.eop_stakeholder_last_name if obj.eop_stakeholder_last_name else ""
|
||||||
|
|
||||||
|
def eop_stakeholder_email(self, obj):
|
||||||
|
return obj.eop_stakeholder_email if obj.eop_stakeholder_email else ""
|
||||||
|
|
||||||
|
eop_stakeholder_first_name.short_description = "EOP Stakeholder First Name" # type: ignore
|
||||||
|
eop_stakeholder_last_name.short_description = "EOP Stakeholder Last Name" # type: ignore
|
||||||
|
eop_stakeholder_email.short_description = "EOP Stakeholder Email" # type: ignore
|
||||||
|
|
||||||
# This is just a placeholder. This field will be populated in the detail_table_fieldset view.
|
# This is just a placeholder. This field will be populated in the detail_table_fieldset view.
|
||||||
# This is not a field that exists on the model.
|
# This is not a field that exists on the model.
|
||||||
def status_history(self, obj):
|
def status_history(self, obj):
|
||||||
|
@ -2615,7 +2649,16 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
(".gov domain", {"fields": ["requested_domain", "alternative_domains"]}),
|
(
|
||||||
|
".gov domain",
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
"requested_domain",
|
||||||
|
"alternative_domains",
|
||||||
|
"feb_naming_requirements_details",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
),
|
||||||
(
|
(
|
||||||
"Contacts",
|
"Contacts",
|
||||||
{
|
{
|
||||||
|
@ -2627,10 +2670,25 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
"cisa_representative_first_name",
|
"cisa_representative_first_name",
|
||||||
"cisa_representative_last_name",
|
"cisa_representative_last_name",
|
||||||
"cisa_representative_email",
|
"cisa_representative_email",
|
||||||
|
"eop_stakeholder_first_name",
|
||||||
|
"eop_stakeholder_last_name",
|
||||||
|
"eop_stakeholder_email",
|
||||||
|
]
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"Background info",
|
||||||
|
{
|
||||||
|
"fields": [
|
||||||
|
"feb_purpose_choice",
|
||||||
|
"purpose",
|
||||||
|
"time_frame_details",
|
||||||
|
"interagency_initiative_details",
|
||||||
|
"anything_else",
|
||||||
|
"current_websites",
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
("Background info", {"fields": ["purpose", "anything_else", "current_websites"]}),
|
|
||||||
(
|
(
|
||||||
"Type of organization",
|
"Type of organization",
|
||||||
{
|
{
|
||||||
|
@ -2781,6 +2839,20 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
||||||
"suborganization_city",
|
"suborganization_city",
|
||||||
"suborganization_state_territory",
|
"suborganization_state_territory",
|
||||||
]
|
]
|
||||||
|
# Hide FEB fields behind the organization requests flag
|
||||||
|
# and only show them if the portfolio is executive
|
||||||
|
if not (obj and obj.portfolio and obj.portfolio.federal_type == BranchChoices.EXECUTIVE):
|
||||||
|
excluded_fields.extend([
|
||||||
|
"feb_naming_requirements_details",
|
||||||
|
"feb_purpose_choice",
|
||||||
|
"time_frame_details",
|
||||||
|
"interagency_initiative_details",
|
||||||
|
"eop_stakeholder_first_name",
|
||||||
|
"eop_stakeholder_last_name",
|
||||||
|
"eop_stakeholder_email",
|
||||||
|
])
|
||||||
|
# This makes .gov domain collapsable underneath Requested By
|
||||||
|
fieldsets[2][1]["classes"] = ["collapse--dgfieldset"]
|
||||||
modified_fieldsets = []
|
modified_fieldsets = []
|
||||||
for name, data in fieldsets:
|
for name, data in fieldsets:
|
||||||
fields = data.get("fields", [])
|
fields = data.get("fields", [])
|
||||||
|
|
|
@ -147,8 +147,6 @@ class EOPContactForm(BaseDeletableRegistrarForm):
|
||||||
Executive Branch (FEB) agency is working with.
|
Executive Branch (FEB) agency is working with.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
field_name = "eop_contact"
|
|
||||||
|
|
||||||
first_name = forms.CharField(
|
first_name = forms.CharField(
|
||||||
label="First name / given name",
|
label="First name / given name",
|
||||||
error_messages={"required": "Enter the first name / given name of this contact."},
|
error_messages={"required": "Enter the first name / given name of this contact."},
|
||||||
|
@ -178,12 +176,10 @@ class EOPContactForm(BaseDeletableRegistrarForm):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_database(cls, obj):
|
def from_database(cls, obj):
|
||||||
if not obj.eop_contact:
|
|
||||||
return {}
|
|
||||||
return {
|
return {
|
||||||
"first_name": obj.eop_contact.first_name,
|
"first_name": obj.eop_stakeholder_first_name,
|
||||||
"last_name": obj.eop_contact.last_name,
|
"last_name": obj.eop_stakeholder_last_name,
|
||||||
"email": obj.eop_contact.email,
|
"email": obj.eop_stakeholder_email,
|
||||||
}
|
}
|
||||||
|
|
||||||
def to_database(self, obj):
|
def to_database(self, obj):
|
||||||
|
@ -195,11 +191,9 @@ class EOPContactForm(BaseDeletableRegistrarForm):
|
||||||
return
|
return
|
||||||
if not self.is_valid():
|
if not self.is_valid():
|
||||||
return
|
return
|
||||||
obj.eop_contact = Contact.objects.create(
|
obj.eop_stakeholder_first_name = self.cleaned_data["first_name"]
|
||||||
first_name=self.cleaned_data["first_name"],
|
obj.eop_stakeholder_last_name = self.cleaned_data["last_name"]
|
||||||
last_name=self.cleaned_data["last_name"],
|
obj.eop_stakeholder_email = self.cleaned_data["email"]
|
||||||
email=self.cleaned_data["email"],
|
|
||||||
)
|
|
||||||
obj.save()
|
obj.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -515,12 +515,15 @@ class DomainRequest(TimeStampedModel):
|
||||||
feb_naming_requirements_details = models.TextField(
|
feb_naming_requirements_details = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
help_text="Required if requested domain that doesn't meet naming requirements",
|
||||||
|
verbose_name="Domain name rationale",
|
||||||
)
|
)
|
||||||
|
|
||||||
feb_purpose_choice = models.CharField(
|
feb_purpose_choice = models.CharField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
choices=FEBPurposeChoices.choices,
|
choices=FEBPurposeChoices.choices,
|
||||||
|
verbose_name="Purpose type",
|
||||||
)
|
)
|
||||||
|
|
||||||
working_with_eop = models.BooleanField(
|
working_with_eop = models.BooleanField(
|
||||||
|
@ -528,17 +531,26 @@ class DomainRequest(TimeStampedModel):
|
||||||
blank=True,
|
blank=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
eop_contact = models.ForeignKey(
|
eop_stakeholder_first_name = models.CharField(
|
||||||
"registrar.Contact",
|
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
related_name="eop_contact",
|
verbose_name="EOP Stakeholder First Name",
|
||||||
on_delete=models.PROTECT,
|
)
|
||||||
|
|
||||||
|
eop_stakeholder_last_name = models.CharField(
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
verbose_name="EOP Stakeholder Last Name",
|
||||||
|
)
|
||||||
|
|
||||||
|
eop_stakeholder_email = models.EmailField(
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
verbose_name="EOP Stakeholder Email",
|
||||||
)
|
)
|
||||||
|
|
||||||
# This field is alternately used for generic domain purpose explanations
|
# This field is alternately used for generic domain purpose explanations
|
||||||
# and for explanations of the specific purpose chosen with feb_purpose_choice
|
# and for explanations of the specific purpose chosen with feb_purpose_choice
|
||||||
# by a Federal Executive Branch agency.
|
|
||||||
purpose = models.TextField(
|
purpose = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
@ -552,6 +564,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
time_frame_details = models.TextField(
|
time_frame_details = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
verbose_name="Target time frame",
|
||||||
)
|
)
|
||||||
|
|
||||||
is_interagency_initiative = models.BooleanField(
|
is_interagency_initiative = models.BooleanField(
|
||||||
|
@ -562,6 +575,7 @@ class DomainRequest(TimeStampedModel):
|
||||||
interagency_initiative_details = models.TextField(
|
interagency_initiative_details = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=True,
|
blank=True,
|
||||||
|
verbose_name="Interagency initiative",
|
||||||
)
|
)
|
||||||
|
|
||||||
alternative_domains = models.ManyToManyField(
|
alternative_domains = models.ManyToManyField(
|
||||||
|
|
|
@ -110,8 +110,8 @@
|
||||||
{% if domain_request.working_with_eop is None %}
|
{% if domain_request.working_with_eop is None %}
|
||||||
<p class="margin-y-0"><span class='text-bold text-secondary-dark'>Incomplete</span></p>
|
<p class="margin-y-0"><span class='text-bold text-secondary-dark'>Incomplete</span></p>
|
||||||
{% elif domain_request.working_with_eop %}
|
{% elif domain_request.working_with_eop %}
|
||||||
<p class="margin-y-0">{{domain_request.eop_contact.first_name}} {{domain_request.eop_contact.last_name}}</p>
|
<p class="margin-y-0">{{domain_request.eop_stakeholder_first_name}} {{domain_request.eop_stakeholder_last_name}}</p>
|
||||||
<p class="margin-y-0">{{domain_request.eop_contact.email}}</p>
|
<p class="margin-y-0">{{domain_request.eop_stakeholder_email}}</p>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p class="margin-y-0">No</p>
|
<p class="margin-y-0">No</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -1985,7 +1985,9 @@ class TestDomainRequestAdmin(MockEppLib):
|
||||||
"feb_naming_requirements_details",
|
"feb_naming_requirements_details",
|
||||||
"feb_purpose_choice",
|
"feb_purpose_choice",
|
||||||
"working_with_eop",
|
"working_with_eop",
|
||||||
"eop_contact",
|
"eop_stakeholder_first_name",
|
||||||
|
"eop_stakeholder_last_name",
|
||||||
|
"eop_stakeholder_email",
|
||||||
"purpose",
|
"purpose",
|
||||||
"has_timeframe",
|
"has_timeframe",
|
||||||
"time_frame_details",
|
"time_frame_details",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue