mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 18:39:21 +02:00
updated for incoming ticket
This commit is contained in:
parent
ff7b4acfa0
commit
a7ec0d573b
3 changed files with 89 additions and 230 deletions
|
@ -1724,26 +1724,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
def converted_state_territory(self, obj):
|
||||
return obj.converted_state_territory
|
||||
|
||||
@admin.display(description=_("Senior Official"))
|
||||
def converted_senior_official(self, obj):
|
||||
return obj.converted_senior_official
|
||||
|
||||
@admin.display(description=_("Address Line 1"))
|
||||
def converted_address_line1(self, obj):
|
||||
return obj.converted_address_line1
|
||||
|
||||
@admin.display(description=_("Address Line 2"))
|
||||
def converted_address_line2(self, obj):
|
||||
return obj.converted_address_line2
|
||||
|
||||
@admin.display(description=_("Zipcode"))
|
||||
def converted_zipcode(self, obj):
|
||||
return obj.converted_zipcode
|
||||
|
||||
@admin.display(description=_("Urbanization"))
|
||||
def converted_urbanization(self, obj):
|
||||
return obj.converted_urbanization
|
||||
|
||||
# Columns
|
||||
list_display = [
|
||||
"requested_domain",
|
||||
|
@ -1798,7 +1778,11 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
]
|
||||
search_help_text = "Search by domain or creator."
|
||||
|
||||
common_fields = [
|
||||
fieldsets = [
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": [
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
"requested_suborganization",
|
||||
|
@ -1815,17 +1799,13 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"approved_domain",
|
||||
"notes",
|
||||
]
|
||||
|
||||
contact_fields_with_portfolio = [
|
||||
"converted_senior_official",
|
||||
"other_contacts",
|
||||
"no_other_contacts_rationale",
|
||||
"cisa_representative_first_name",
|
||||
"cisa_representative_last_name",
|
||||
"cisa_representative_email",
|
||||
]
|
||||
|
||||
contact_fields_without_portfolio = [
|
||||
},
|
||||
),
|
||||
(".gov domain", {"fields": ["requested_domain", "alternative_domains"]}),
|
||||
(
|
||||
"Contacts",
|
||||
{
|
||||
"fields": [
|
||||
"senior_official",
|
||||
"other_contacts",
|
||||
"no_other_contacts_rationale",
|
||||
|
@ -1833,60 +1813,56 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"cisa_representative_last_name",
|
||||
"cisa_representative_email",
|
||||
]
|
||||
|
||||
background_fields = ["purpose", "anything_else", "current_websites"]
|
||||
|
||||
extends_type_of_org_base_end = [
|
||||
},
|
||||
),
|
||||
("Background info", {"fields": ["purpose", "anything_else", "current_websites"]}),
|
||||
(
|
||||
"Type of organization",
|
||||
{
|
||||
"fields": [
|
||||
"is_election_board",
|
||||
"organization_type",
|
||||
]
|
||||
},
|
||||
),
|
||||
(
|
||||
"Show details",
|
||||
{
|
||||
"classes": ["collapse--dgfieldset"],
|
||||
"description": "Extends type of organization",
|
||||
"fields": [
|
||||
"federal_type",
|
||||
"federal_agency",
|
||||
"tribe_name",
|
||||
"federally_recognized_tribe",
|
||||
"state_recognized_tribe",
|
||||
"about_your_organization",
|
||||
]
|
||||
|
||||
extends_type_of_org_without_portfolio_start = [
|
||||
"federal_type",
|
||||
"federal_agency",
|
||||
]
|
||||
|
||||
extends_type_of_org_with_portfolio_start = [
|
||||
"converted_federal_type",
|
||||
"converted_federal_agency",
|
||||
]
|
||||
|
||||
organization_address_fields_with_portfolio = [
|
||||
"converted_organization_name",
|
||||
"converted_state_territory",
|
||||
]
|
||||
|
||||
organization_address_fields_without_portfolio = [
|
||||
],
|
||||
},
|
||||
),
|
||||
(
|
||||
"Organization name and mailing address",
|
||||
{
|
||||
"fields": [
|
||||
"organization_name",
|
||||
"state_territory",
|
||||
]
|
||||
|
||||
type_of_org_fields_with_portfolio = [
|
||||
"is_election_board",
|
||||
"converted_generic_org_type",
|
||||
]
|
||||
|
||||
type_of_org_fields_without_portfolio = [
|
||||
"is_election_board",
|
||||
"generic_org_type",
|
||||
]
|
||||
|
||||
show_details_address_with_portfolio = [
|
||||
"converted_address_line1",
|
||||
"converted_address_line2",
|
||||
"converted_city",
|
||||
"converted_zipcode",
|
||||
"converted_urbanization",
|
||||
]
|
||||
|
||||
show_details_address_without_portfolio = [
|
||||
},
|
||||
),
|
||||
(
|
||||
"Show details",
|
||||
{
|
||||
"classes": ["collapse--dgfieldset"],
|
||||
"description": "Extends organization name and mailing address",
|
||||
"fields": [
|
||||
"address_line1",
|
||||
"address_line2",
|
||||
"city",
|
||||
"zipcode",
|
||||
"urbanization",
|
||||
],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
# Readonly fields for analysts and superusers
|
||||
|
@ -1898,34 +1874,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
"status_history",
|
||||
)
|
||||
|
||||
readonly_fields_with_portfolio = [
|
||||
"converted_senior_official",
|
||||
"converted_federal_type",
|
||||
"converted_federal_agency",
|
||||
"converted_state_territory",
|
||||
"converted_organization_name",
|
||||
"converted_address_line1",
|
||||
"converted_address_line2",
|
||||
"converted_zipcode",
|
||||
"converted_urbanization",
|
||||
"converted_city",
|
||||
"converted_generic_org_type",
|
||||
]
|
||||
|
||||
readonly_fields_without_portfolio = [
|
||||
"senior_official",
|
||||
"federal_type",
|
||||
"federal_agency",
|
||||
"state_territory",
|
||||
"organization_name",
|
||||
"address_line1",
|
||||
"address_line2",
|
||||
"zipcode",
|
||||
"urbanization",
|
||||
"city",
|
||||
"generic_org_type",
|
||||
]
|
||||
|
||||
# Read only that we'll leverage for CISA Analysts
|
||||
analyst_readonly_fields = [
|
||||
"converted_federal_agency",
|
||||
|
@ -1965,73 +1913,16 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
change_form_template = "django/admin/domain_request_change_form.html"
|
||||
|
||||
def get_fieldsets(self, request, obj=None):
|
||||
# fieldsets = list(super().get_fieldsets(request, obj)) # Get the default fieldsets
|
||||
has_portfolio = obj and obj.portfolio # Check once for portfolio presence
|
||||
fieldsets = super().get_fieldsets(request, obj)
|
||||
|
||||
# Common fields
|
||||
fieldsets = [(None, {"fields": self.common_fields})]
|
||||
fieldsets.append((".gov domain", {"fields": ["requested_domain", "alternative_domains"]}))
|
||||
|
||||
# Contacts fields based on portfolio
|
||||
contacts_fields = self.contact_fields_with_portfolio if has_portfolio else self.contact_fields_without_portfolio
|
||||
fieldsets.append(("Contacts", {"fields": contacts_fields}))
|
||||
|
||||
# Background info
|
||||
fieldsets.append(("Background info", {"fields": self.background_fields}))
|
||||
|
||||
# Type of organization based on portfolio
|
||||
type_of_org_fields = (
|
||||
self.type_of_org_fields_with_portfolio if has_portfolio else self.type_of_org_fields_without_portfolio
|
||||
)
|
||||
fieldsets.append(("Type of organization", {"fields": type_of_org_fields}))
|
||||
|
||||
fieldsets.append(
|
||||
(
|
||||
"Show details",
|
||||
{
|
||||
"classes": ["collapse--dgfieldset"],
|
||||
"description": "Extends type of organization",
|
||||
"fields": (
|
||||
self.extends_type_of_org_with_portfolio_start
|
||||
if has_portfolio
|
||||
else self.extends_type_of_org_without_portfolio_start + self.extends_type_of_org_base_end
|
||||
),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
# Organization name and address
|
||||
address_fields = (
|
||||
self.organization_address_fields_with_portfolio
|
||||
if has_portfolio
|
||||
else self.organization_address_fields_without_portfolio
|
||||
)
|
||||
fieldsets.append(("Organization name and mailing address", {"fields": address_fields}))
|
||||
|
||||
# Additional "Show details" sections
|
||||
fieldsets.append(
|
||||
(
|
||||
"Show details",
|
||||
{
|
||||
"classes": ["collapse--dgfieldset"],
|
||||
"description": "Extends organization name and mailing address",
|
||||
"fields": (
|
||||
self.show_details_address_with_portfolio
|
||||
if has_portfolio
|
||||
else self.show_details_address_without_portfolio
|
||||
),
|
||||
},
|
||||
)
|
||||
)
|
||||
|
||||
# Flag-based field exclusion
|
||||
# Hide certain suborg fields behind the organization feature flag
|
||||
# if it is not enabled
|
||||
if not flag_is_active_for_user(request.user, "organization_feature"):
|
||||
excluded_fields = [
|
||||
"requested_suborganization",
|
||||
"suborganization_city",
|
||||
"suborganization_state_territory",
|
||||
]
|
||||
# Filter out the excluded fields
|
||||
fieldsets = [
|
||||
(name, {**data, "fields": [f for f in data["fields"] if f not in excluded_fields]})
|
||||
for name, data in fieldsets
|
||||
|
@ -2229,8 +2120,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
we'll use the baseline readonly_fields and extend it as needed.
|
||||
"""
|
||||
readonly_fields = list(self.readonly_fields)
|
||||
if obj and obj.portfolio:
|
||||
readonly_fields.extend(self.readonly_fields_with_portfolio)
|
||||
# Check if the creator is restricted
|
||||
if obj and obj.creator.status == models.User.RESTRICTED:
|
||||
# For fields like CharField, IntegerField, etc., the widget used is
|
||||
|
|
|
@ -1437,24 +1437,6 @@ class DomainRequest(TimeStampedModel):
|
|||
return self.portfolio.federal_type
|
||||
return self.federal_type
|
||||
|
||||
@property
|
||||
def converted_senior_official(self):
|
||||
if self.portfolio:
|
||||
return self.portfolio.senior_official
|
||||
return self.senior_official
|
||||
|
||||
@property
|
||||
def converted_address_line1(self):
|
||||
if self.portfolio:
|
||||
return self.portfolio.address_line1
|
||||
return self.address_line1
|
||||
|
||||
@property
|
||||
def converted_address_line2(self):
|
||||
if self.portfolio:
|
||||
return self.portfolio.address_line2
|
||||
return self.address_line2
|
||||
|
||||
@property
|
||||
def converted_city(self):
|
||||
if self.portfolio:
|
||||
|
@ -1466,15 +1448,3 @@ class DomainRequest(TimeStampedModel):
|
|||
if self.portfolio:
|
||||
return self.portfolio.state_territory
|
||||
return self.state_territory
|
||||
|
||||
@property
|
||||
def converted_zipcode(self):
|
||||
if self.portfolio:
|
||||
return self.portfolio.zipcode
|
||||
return self.zipcode
|
||||
|
||||
@property
|
||||
def converted_urbanization(self):
|
||||
if self.portfolio:
|
||||
return self.portfolio.urbanization
|
||||
return self.urbanization
|
||||
|
|
|
@ -327,7 +327,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
|
|||
{% if not skip_additional_contact_info %}
|
||||
{% include "django/admin/includes/user_detail_list.html" with user=original_object.creator no_title_top_padding=field.is_readonly %}
|
||||
{% endif%}
|
||||
{% elif field.field.name == "senior_official" or field.field.name == "converted_senior_official" %}
|
||||
{% elif field.field.name == "senior_official" %}
|
||||
<div class="flex-container">
|
||||
<label aria-label="Senior official contact details"></label>
|
||||
{% include "django/admin/includes/contact_detail_list.html" with user=original_object.senior_official no_title_top_padding=field.is_readonly %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue