mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
linting + add fields to django admin
This commit is contained in:
parent
87d51c1002
commit
178d12711a
7 changed files with 143 additions and 17 deletions
|
@ -1478,7 +1478,21 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
|
|||
search_help_text = "Search by domain."
|
||||
|
||||
fieldsets = [
|
||||
(None, {"fields": ["portfolio", "sub_organization", "creator", "domain_request", "notes"]}),
|
||||
(
|
||||
None,
|
||||
{
|
||||
"fields": [
|
||||
"portfolio",
|
||||
"sub_organization",
|
||||
"requested_suborganization",
|
||||
"suborganization_city",
|
||||
"suborganization_state_territory",
|
||||
"creator",
|
||||
"domain_request",
|
||||
"notes",
|
||||
]
|
||||
},
|
||||
),
|
||||
(".gov domain", {"fields": ["domain"]}),
|
||||
("Contacts", {"fields": ["senior_official", "other_contacts", "no_other_contacts_rationale"]}),
|
||||
("Background info", {"fields": ["anything_else"]}),
|
||||
|
|
|
@ -68,7 +68,9 @@ class RequestingEntityForm(RegistrarForm):
|
|||
super().__init__(*args, **kwargs)
|
||||
|
||||
if self.domain_request.portfolio:
|
||||
self.fields["sub_organization"].queryset = Suborganization.objects.filter(portfolio=self.domain_request.portfolio)
|
||||
self.fields["sub_organization"].queryset = Suborganization.objects.filter(
|
||||
portfolio=self.domain_request.portfolio
|
||||
)
|
||||
|
||||
def clean_sub_organization(self):
|
||||
sub_organization = self.cleaned_data.get("sub_organization")
|
||||
|
@ -82,11 +84,11 @@ class RequestingEntityForm(RegistrarForm):
|
|||
def full_clean(self):
|
||||
# Remove the custom other field before cleaning
|
||||
data = self.data.copy() if self.data else None
|
||||
suborganization = self.data.get('portfolio_requesting_entity-sub_organization')
|
||||
suborganization = self.data.get("portfolio_requesting_entity-sub_organization")
|
||||
if suborganization:
|
||||
if "other" in data['portfolio_requesting_entity-sub_organization']:
|
||||
if "other" in data["portfolio_requesting_entity-sub_organization"]:
|
||||
# Remove the 'other' value
|
||||
data['portfolio_requesting_entity-sub_organization'] = ""
|
||||
data["portfolio_requesting_entity-sub_organization"] = ""
|
||||
|
||||
# Set the modified data back to the form
|
||||
self.data = data
|
||||
|
@ -129,7 +131,10 @@ class RequestingEntityYesNoForm(BaseYesNoForm):
|
|||
"""Extend the initialization of the form from RegistrarForm __init__"""
|
||||
super().__init__(*args, **kwargs)
|
||||
if self.domain_request.portfolio:
|
||||
self.form_choices = ((False, self.domain_request.portfolio), (True, "A suborganization. (choose from list)"))
|
||||
self.form_choices = (
|
||||
(False, self.domain_request.portfolio),
|
||||
(True, "A suborganization. (choose from list)"),
|
||||
)
|
||||
self.fields[self.field_name] = self.get_typed_choice_field()
|
||||
|
||||
@property
|
||||
|
@ -138,13 +143,17 @@ class RequestingEntityYesNoForm(BaseYesNoForm):
|
|||
Determines the initial checked state of the form based on the domain_request's attributes.
|
||||
"""
|
||||
|
||||
if self.domain_request.portfolio and self.domain_request.organization_name == self.domain_request.portfolio.organization_name:
|
||||
if (
|
||||
self.domain_request.portfolio
|
||||
and self.domain_request.organization_name == self.domain_request.portfolio.organization_name
|
||||
):
|
||||
return False
|
||||
elif self.domain_request.is_suborganization():
|
||||
return True
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class OrganizationTypeForm(RegistrarForm):
|
||||
generic_org_type = forms.ChoiceField(
|
||||
# use the long names in the domain request form
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Generated by Django 4.2.10 on 2024-10-23 19:15
|
||||
# Generated by Django 4.2.10 on 2024-10-24 16:30
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
@ -13,6 +13,88 @@ class Migration(migrations.Migration):
|
|||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="requested_suborganization",
|
||||
field=models.CharField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="suborganization_city",
|
||||
field=models.CharField(blank=True, null=True),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domaininformation",
|
||||
name="suborganization_state_territory",
|
||||
field=models.CharField(
|
||||
blank=True,
|
||||
choices=[
|
||||
("AL", "Alabama (AL)"),
|
||||
("AK", "Alaska (AK)"),
|
||||
("AS", "American Samoa (AS)"),
|
||||
("AZ", "Arizona (AZ)"),
|
||||
("AR", "Arkansas (AR)"),
|
||||
("CA", "California (CA)"),
|
||||
("CO", "Colorado (CO)"),
|
||||
("CT", "Connecticut (CT)"),
|
||||
("DE", "Delaware (DE)"),
|
||||
("DC", "District of Columbia (DC)"),
|
||||
("FL", "Florida (FL)"),
|
||||
("GA", "Georgia (GA)"),
|
||||
("GU", "Guam (GU)"),
|
||||
("HI", "Hawaii (HI)"),
|
||||
("ID", "Idaho (ID)"),
|
||||
("IL", "Illinois (IL)"),
|
||||
("IN", "Indiana (IN)"),
|
||||
("IA", "Iowa (IA)"),
|
||||
("KS", "Kansas (KS)"),
|
||||
("KY", "Kentucky (KY)"),
|
||||
("LA", "Louisiana (LA)"),
|
||||
("ME", "Maine (ME)"),
|
||||
("MD", "Maryland (MD)"),
|
||||
("MA", "Massachusetts (MA)"),
|
||||
("MI", "Michigan (MI)"),
|
||||
("MN", "Minnesota (MN)"),
|
||||
("MS", "Mississippi (MS)"),
|
||||
("MO", "Missouri (MO)"),
|
||||
("MT", "Montana (MT)"),
|
||||
("NE", "Nebraska (NE)"),
|
||||
("NV", "Nevada (NV)"),
|
||||
("NH", "New Hampshire (NH)"),
|
||||
("NJ", "New Jersey (NJ)"),
|
||||
("NM", "New Mexico (NM)"),
|
||||
("NY", "New York (NY)"),
|
||||
("NC", "North Carolina (NC)"),
|
||||
("ND", "North Dakota (ND)"),
|
||||
("MP", "Northern Mariana Islands (MP)"),
|
||||
("OH", "Ohio (OH)"),
|
||||
("OK", "Oklahoma (OK)"),
|
||||
("OR", "Oregon (OR)"),
|
||||
("PA", "Pennsylvania (PA)"),
|
||||
("PR", "Puerto Rico (PR)"),
|
||||
("RI", "Rhode Island (RI)"),
|
||||
("SC", "South Carolina (SC)"),
|
||||
("SD", "South Dakota (SD)"),
|
||||
("TN", "Tennessee (TN)"),
|
||||
("TX", "Texas (TX)"),
|
||||
("UM", "United States Minor Outlying Islands (UM)"),
|
||||
("UT", "Utah (UT)"),
|
||||
("VT", "Vermont (VT)"),
|
||||
("VI", "Virgin Islands (VI)"),
|
||||
("VA", "Virginia (VA)"),
|
||||
("WA", "Washington (WA)"),
|
||||
("WV", "West Virginia (WV)"),
|
||||
("WI", "Wisconsin (WI)"),
|
||||
("WY", "Wyoming (WY)"),
|
||||
("AA", "Armed Forces Americas (AA)"),
|
||||
("AE", "Armed Forces Africa, Canada, Europe, Middle East (AE)"),
|
||||
("AP", "Armed Forces Pacific (AP)"),
|
||||
],
|
||||
max_length=2,
|
||||
null=True,
|
||||
verbose_name="state, territory, or military post",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="domainrequest",
|
||||
name="requested_suborganization",
|
|
@ -75,6 +75,24 @@ class DomainInformation(TimeStampedModel):
|
|||
verbose_name="Suborganization",
|
||||
)
|
||||
|
||||
requested_suborganization = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
suborganization_city = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
)
|
||||
|
||||
suborganization_state_territory = models.CharField(
|
||||
max_length=2,
|
||||
choices=StateTerritoryChoices.choices,
|
||||
null=True,
|
||||
blank=True,
|
||||
verbose_name="state, territory, or military post",
|
||||
)
|
||||
|
||||
domain_request = models.OneToOneField(
|
||||
"registrar.DomainRequest",
|
||||
on_delete=models.PROTECT,
|
||||
|
|
|
@ -1129,7 +1129,7 @@ class DomainRequest(TimeStampedModel):
|
|||
# Form unlocking steps
|
||||
# These methods control the conditions in which we should unlock certain domain wizard steps.
|
||||
def unlock_requesting_entity(self) -> bool:
|
||||
"""Unlocks the requesting entity step """
|
||||
"""Unlocks the requesting entity step"""
|
||||
if self.portfolio and self.organization_name == self.portfolio.organization_name:
|
||||
return True
|
||||
else:
|
||||
|
@ -1230,7 +1230,8 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
def has_information_required_to_make_suborganization(self) -> bool:
|
||||
"""Checks if we have all the information we need to create a new suborganization object.
|
||||
Checks for a the existence of requested_suborganization, suborganization_city, suborganization_state_territory"""
|
||||
Checks for a the existence of requested_suborganization, suborganization_city, suborganization_state_territory
|
||||
"""
|
||||
if self.requested_suborganization and self.suborganization_city and self.suborganization_state_territory:
|
||||
return True
|
||||
else:
|
||||
|
|
|
@ -258,6 +258,7 @@ def portfolio_role_summary(user, portfolio):
|
|||
else:
|
||||
return []
|
||||
|
||||
|
||||
@register.filter(name="display_requesting_entity")
|
||||
def display_requesting_entity(domain_request):
|
||||
"""Workaround for a newline issue in .txt files (our emails) as if statements
|
||||
|
|
|
@ -614,6 +614,7 @@ class RequestingEntity(DomainRequestWizard):
|
|||
|
||||
super().save(forms)
|
||||
|
||||
|
||||
class PortfolioAdditionalDetails(DomainRequestWizard):
|
||||
template_name = "portfolio_domain_request_additional_details.html"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue