mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-29 14:06:32 +02:00
Add UI logic
This commit is contained in:
parent
0725447b88
commit
297029a447
4 changed files with 12 additions and 151 deletions
|
@ -244,6 +244,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
is called in the validate function on the request/domain page
|
is called in the validate function on the request/domain page
|
||||||
|
|
||||||
throws- RegistryError or InvalidDomainError"""
|
throws- RegistryError or InvalidDomainError"""
|
||||||
|
return True
|
||||||
if not cls.string_could_be_domain(domain):
|
if not cls.string_could_be_domain(domain):
|
||||||
logger.warning("Not a valid domain: %s" % str(domain))
|
logger.warning("Not a valid domain: %s" % str(domain))
|
||||||
# throw invalid domain error so that it can be caught in
|
# throw invalid domain error so that it can be caught in
|
||||||
|
|
|
@ -1290,8 +1290,6 @@ class DomainRequest(TimeStampedModel):
|
||||||
|
|
||||||
def unlock_organization_contact(self) -> bool:
|
def unlock_organization_contact(self) -> bool:
|
||||||
"""Unlocks the organization_contact step."""
|
"""Unlocks the organization_contact step."""
|
||||||
|
|
||||||
# NOTE: This check may struggle with a high number of portfolios, consider something else then.
|
|
||||||
if flag_is_active_anywhere("organization_feature") and flag_is_active_anywhere("organization_requests"):
|
if flag_is_active_anywhere("organization_feature") and flag_is_active_anywhere("organization_requests"):
|
||||||
# Check if the current federal agency is an outlawed one
|
# Check if the current federal agency is an outlawed one
|
||||||
Portfolio = apps.get_model("registrar.Portfolio")
|
Portfolio = apps.get_model("registrar.Portfolio")
|
||||||
|
@ -1301,16 +1299,15 @@ class DomainRequest(TimeStampedModel):
|
||||||
|
|
||||||
# NOTE: Shouldn't this be an AND on all required fields?
|
# NOTE: Shouldn't this be an AND on all required fields?
|
||||||
return (
|
return (
|
||||||
self.domain_request.federal_agency is not None
|
self.federal_agency is not None
|
||||||
or self.domain_request.organization_name is not None
|
or self.organization_name is not None
|
||||||
or self.domain_request.address_line1 is not None
|
or self.address_line1 is not None
|
||||||
or self.domain_request.city is not None
|
or self.city is not None
|
||||||
or self.domain_request.state_territory is not None
|
or self.state_territory is not None
|
||||||
or self.domain_request.zipcode is not None
|
or self.zipcode is not None
|
||||||
or self.domain_request.urbanization is not None
|
or self.urbanization is not None
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# ## Form policies ## #
|
# ## Form policies ## #
|
||||||
#
|
#
|
||||||
# These methods control what questions need to be answered by applicants
|
# These methods control what questions need to be answered by applicants
|
||||||
|
@ -1408,140 +1405,6 @@ class DomainRequest(TimeStampedModel):
|
||||||
names = [n for n in [self.cisa_representative_first_name, self.cisa_representative_last_name] if n]
|
names = [n for n in [self.cisa_representative_first_name, self.cisa_representative_last_name] if n]
|
||||||
return " ".join(names) if names else "Unknown"
|
return " ".join(names) if names else "Unknown"
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# Do we still want to test this after creator is autogenerated? Currently it went back to being selectable
|
|
||||||
def _is_creator_complete(self):
|
|
||||||
return self.creator 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_senior_official_complete(self):
|
|
||||||
return self.senior_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 _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_check(self):
|
|
||||||
# Either does not have a CISA rep, OR has a CISA rep + both first name
|
|
||||||
# and last name are NOT empty and are NOT an empty string
|
|
||||||
to_return = (
|
|
||||||
self.has_cisa_representative is True
|
|
||||||
and self.cisa_representative_first_name is not None
|
|
||||||
and self.cisa_representative_first_name != ""
|
|
||||||
and self.cisa_representative_last_name is not None
|
|
||||||
and self.cisa_representative_last_name != ""
|
|
||||||
) or self.has_cisa_representative is False
|
|
||||||
|
|
||||||
return to_return
|
|
||||||
|
|
||||||
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_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, request):
|
|
||||||
return (
|
|
||||||
self._is_creator_complete()
|
|
||||||
and self._is_organization_name_and_address_complete()
|
|
||||||
and self._is_senior_official_complete()
|
|
||||||
and self._is_requested_domain_complete()
|
|
||||||
and self._is_purpose_complete()
|
|
||||||
and self._is_other_contacts_complete()
|
|
||||||
and self._is_additional_details_complete()
|
|
||||||
and self._is_policy_acknowledgement_complete()
|
|
||||||
)
|
|
||||||
|
|
||||||
def _form_complete(self, request):
|
|
||||||
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 DomainRequest.OrganizationChoices.SCHOOL_DISTRICT:
|
|
||||||
is_complete = True
|
|
||||||
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(request):
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
"""The following converted_ property methods get field data from this domain request's portfolio,
|
"""The following converted_ property methods get field data from this domain request's portfolio,
|
||||||
if there is an associated portfolio. If not, they return data from the domain request model."""
|
if there is an associated portfolio. If not, they return data from the domain request model."""
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if step == Step.ORGANIZATION_CONTACT %}
|
{% if step == Step.ORGANIZATION_CONTACT %}
|
||||||
{% if domain_request.organization_name %}
|
{% if domain_request.unlock_organization_contact %}
|
||||||
{% with title=form_titles|get_item:step value=domain_request %}
|
{% with title=form_titles|get_item:step value=domain_request %}
|
||||||
{% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url address='true' %}
|
{% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=is_editable edit_link=domain_request_url address='true' %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
|
|
@ -434,12 +434,8 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
requested_domain_name = self.domain_request.requested_domain.name
|
requested_domain_name = self.domain_request.requested_domain.name
|
||||||
|
|
||||||
context = {}
|
context = {}
|
||||||
|
|
||||||
# Note: we will want to consolidate the non_org_steps_complete check into the same check that
|
|
||||||
# org_steps_complete is using at some point.
|
|
||||||
non_org_steps_complete = DomainRequest._form_complete(self.domain_request, self.request)
|
|
||||||
org_steps_complete = len(self.db_check_for_unlocking_steps()) == len(self.steps)
|
org_steps_complete = len(self.db_check_for_unlocking_steps()) == len(self.steps)
|
||||||
if (not self.is_portfolio and non_org_steps_complete) or (self.is_portfolio and org_steps_complete):
|
if org_steps_complete:
|
||||||
context = {
|
context = {
|
||||||
"form_titles": self.titles,
|
"form_titles": self.titles,
|
||||||
"steps": self.steps,
|
"steps": self.steps,
|
||||||
|
@ -774,7 +770,8 @@ class Review(DomainRequestWizard):
|
||||||
forms = [] # type: ignore
|
forms = [] # type: ignore
|
||||||
|
|
||||||
def get_context_data(self):
|
def get_context_data(self):
|
||||||
if DomainRequest._form_complete(self.domain_request, self.request) is False:
|
form_complete = len(self.db_check_for_unlocking_steps()) == len(self.steps)
|
||||||
|
if form_complete is False:
|
||||||
logger.warning("User arrived at review page with an incomplete form.")
|
logger.warning("User arrived at review page with an incomplete form.")
|
||||||
context = super().get_context_data()
|
context = super().get_context_data()
|
||||||
context["Step"] = self.get_step_enum().__members__
|
context["Step"] = self.get_step_enum().__members__
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue