mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Merge branch 'main' into gd/1900-add-action-needed-reason
This commit is contained in:
commit
b931804ac2
66 changed files with 11060 additions and 568 deletions
|
@ -24,6 +24,15 @@ logger = logging.getLogger(__name__)
|
|||
class DomainRequest(TimeStampedModel):
|
||||
"""A registrant's domain request for a new domain."""
|
||||
|
||||
class Meta:
|
||||
"""Contains meta information about this class"""
|
||||
|
||||
indexes = [
|
||||
models.Index(fields=["requested_domain"]),
|
||||
models.Index(fields=["approved_domain"]),
|
||||
models.Index(fields=["status"]),
|
||||
]
|
||||
|
||||
# https://django-auditlog.readthedocs.io/en/latest/usage.html#object-history
|
||||
# If we note any performace degradation due to this addition,
|
||||
# we can query the auditlogs table in admin.py and add the results to
|
||||
|
@ -345,7 +354,6 @@ class DomainRequest(TimeStampedModel):
|
|||
organization_name = models.CharField(
|
||||
null=True,
|
||||
blank=True,
|
||||
db_index=True,
|
||||
)
|
||||
|
||||
address_line1 = models.CharField(
|
||||
|
@ -374,7 +382,6 @@ class DomainRequest(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
verbose_name="zip code",
|
||||
db_index=True,
|
||||
)
|
||||
urbanization = models.CharField(
|
||||
null=True,
|
||||
|
@ -1015,3 +1022,131 @@ class DomainRequest(TimeStampedModel):
|
|||
for field in opts.many_to_many:
|
||||
data[field.name] = field.value_from_object(self)
|
||||
return data
|
||||
|
||||
def _is_federal_complete(self):
|
||||
# Federal -> "Federal government branch" page can't be empty + Federal Agency selection can't be None
|
||||
return not (self.federal_type is None or self.federal_agency is None)
|
||||
|
||||
def _is_interstate_complete(self):
|
||||
# Interstate -> "About your organization" page can't be empty
|
||||
return self.about_your_organization is not None
|
||||
|
||||
def _is_state_or_territory_complete(self):
|
||||
# State -> ""Election office" page can't be empty
|
||||
return self.is_election_board is not None
|
||||
|
||||
def _is_tribal_complete(self):
|
||||
# Tribal -> "Tribal name" and "Election office" page can't be empty
|
||||
return self.tribe_name is not None and self.is_election_board is not None
|
||||
|
||||
def _is_county_complete(self):
|
||||
# County -> "Election office" page can't be empty
|
||||
return self.is_election_board is not None
|
||||
|
||||
def _is_city_complete(self):
|
||||
# City -> "Election office" page can't be empty
|
||||
return self.is_election_board is not None
|
||||
|
||||
def _is_special_district_complete(self):
|
||||
# Special District -> "Election office" and "About your organization" page can't be empty
|
||||
return self.is_election_board is not None and self.about_your_organization is not None
|
||||
|
||||
def _is_organization_name_and_address_complete(self):
|
||||
return not (
|
||||
self.organization_name is None
|
||||
and self.address_line1 is None
|
||||
and self.city is None
|
||||
and self.state_territory is None
|
||||
and self.zipcode is None
|
||||
)
|
||||
|
||||
def _is_authorizing_official_complete(self):
|
||||
return self.authorizing_official is not None
|
||||
|
||||
def _is_requested_domain_complete(self):
|
||||
return self.requested_domain is not None
|
||||
|
||||
def _is_purpose_complete(self):
|
||||
return self.purpose is not None
|
||||
|
||||
def _is_submitter_complete(self):
|
||||
return self.submitter is not None
|
||||
|
||||
def _has_other_contacts_and_filled(self):
|
||||
# Other Contacts Radio button is Yes and if all required fields are filled
|
||||
return (
|
||||
self.has_other_contacts()
|
||||
and self.other_contacts.filter(
|
||||
first_name__isnull=False,
|
||||
last_name__isnull=False,
|
||||
title__isnull=False,
|
||||
email__isnull=False,
|
||||
phone__isnull=False,
|
||||
).exists()
|
||||
)
|
||||
|
||||
def _has_no_other_contacts_gives_rationale(self):
|
||||
# Other Contacts Radio button is No and a rationale is provided
|
||||
return self.has_other_contacts() is False and self.no_other_contacts_rationale is not None
|
||||
|
||||
def _is_other_contacts_complete(self):
|
||||
if self._has_other_contacts_and_filled() or self._has_no_other_contacts_gives_rationale():
|
||||
return True
|
||||
return False
|
||||
|
||||
def _cisa_rep_and_email_check(self):
|
||||
# Has a CISA rep + email is NOT empty or NOT an empty string OR doesn't have CISA rep
|
||||
return (
|
||||
self.has_cisa_representative is True
|
||||
and self.cisa_representative_email is not None
|
||||
and self.cisa_representative_email != ""
|
||||
) or self.has_cisa_representative is False
|
||||
|
||||
def _anything_else_radio_button_and_text_field_check(self):
|
||||
# Anything else boolean is True + filled text field and it's not an empty string OR the boolean is No
|
||||
return (
|
||||
self.has_anything_else_text is True and self.anything_else is not None and self.anything_else != ""
|
||||
) or self.has_anything_else_text is False
|
||||
|
||||
def _is_additional_details_complete(self):
|
||||
return self._cisa_rep_and_email_check() and self._anything_else_radio_button_and_text_field_check()
|
||||
|
||||
def _is_policy_acknowledgement_complete(self):
|
||||
return self.is_policy_acknowledged is not None
|
||||
|
||||
def _is_general_form_complete(self):
|
||||
return (
|
||||
self._is_organization_name_and_address_complete()
|
||||
and self._is_authorizing_official_complete()
|
||||
and self._is_requested_domain_complete()
|
||||
and self._is_purpose_complete()
|
||||
and self._is_submitter_complete()
|
||||
and self._is_other_contacts_complete()
|
||||
and self._is_additional_details_complete()
|
||||
and self._is_policy_acknowledgement_complete()
|
||||
)
|
||||
|
||||
def _form_complete(self):
|
||||
match self.generic_org_type:
|
||||
case DomainRequest.OrganizationChoices.FEDERAL:
|
||||
is_complete = self._is_federal_complete()
|
||||
case DomainRequest.OrganizationChoices.INTERSTATE:
|
||||
is_complete = self._is_interstate_complete()
|
||||
case DomainRequest.OrganizationChoices.STATE_OR_TERRITORY:
|
||||
is_complete = self._is_state_or_territory_complete()
|
||||
case DomainRequest.OrganizationChoices.TRIBAL:
|
||||
is_complete = self._is_tribal_complete()
|
||||
case DomainRequest.OrganizationChoices.COUNTY:
|
||||
is_complete = self._is_county_complete()
|
||||
case DomainRequest.OrganizationChoices.CITY:
|
||||
is_complete = self._is_city_complete()
|
||||
case DomainRequest.OrganizationChoices.SPECIAL_DISTRICT:
|
||||
is_complete = self._is_special_district_complete()
|
||||
case _:
|
||||
# NOTE: Shouldn't happen, this is only if somehow they didn't choose an org type
|
||||
is_complete = False
|
||||
|
||||
if not is_complete or not self._is_general_form_complete():
|
||||
return False
|
||||
|
||||
return True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue