mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Caught and fixed gap in design and form verification logic
This commit is contained in:
parent
6bcc084df7
commit
429875199d
4 changed files with 84 additions and 26 deletions
|
@ -125,6 +125,7 @@ class Command(BaseCommand):
|
||||||
if request_is_approved and domain_name is not None and not request.is_election_board:
|
if request_is_approved and domain_name is not None and not request.is_election_board:
|
||||||
request.is_election_board = domain_name in self.domains_with_election_boards_set
|
request.is_election_board = domain_name in self.domains_with_election_boards_set
|
||||||
|
|
||||||
|
self.sync_yes_no_form_fields()
|
||||||
self.sync_organization_type(DomainRequest, request)
|
self.sync_organization_type(DomainRequest, request)
|
||||||
self.request_to_update.append(request)
|
self.request_to_update.append(request)
|
||||||
logger.info(f"Updating {request} => {request.organization_type}")
|
logger.info(f"Updating {request} => {request.organization_type}")
|
||||||
|
@ -175,6 +176,7 @@ class Command(BaseCommand):
|
||||||
if not info.is_election_board:
|
if not info.is_election_board:
|
||||||
info.is_election_board = domain_name in self.domains_with_election_boards_set
|
info.is_election_board = domain_name in self.domains_with_election_boards_set
|
||||||
|
|
||||||
|
self.sync_yes_no_form_fields()
|
||||||
self.sync_organization_type(DomainInformation, info)
|
self.sync_organization_type(DomainInformation, info)
|
||||||
|
|
||||||
self.di_to_update.append(info)
|
self.di_to_update.append(info)
|
||||||
|
|
|
@ -255,6 +255,33 @@ class DomainInformation(TimeStampedModel):
|
||||||
except Exception:
|
except Exception:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def sync_yes_no_form_fields(self):
|
||||||
|
"""Some yes/no forms use a db field to track whether it was checked or not.
|
||||||
|
We handle that here for def save().
|
||||||
|
"""
|
||||||
|
logger.debug("\033[96m .....syncing form (domain info)...... \033[0m") # TODO-nl: delete me!
|
||||||
|
# This ensures that if we have prefilled data, the form is prepopulated
|
||||||
|
if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None:
|
||||||
|
logger.debug("\033[96m --> NO NONES \033[0m") # TODO-nl: delete me!
|
||||||
|
self.has_cisa_representative = (
|
||||||
|
self.cisa_representative_first_name != "" and self.cisa_representative_last_name != ""
|
||||||
|
)
|
||||||
|
|
||||||
|
# This check is required to ensure that the form doesn't start out checked
|
||||||
|
if self.has_cisa_representative is not None:
|
||||||
|
logger.debug("\033[96m --> cisa_rep is not none \033[0m") # TODO-nl: delete me!
|
||||||
|
self.has_cisa_representative = (
|
||||||
|
self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None
|
||||||
|
) and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None)
|
||||||
|
|
||||||
|
# This ensures that if we have prefilled data, the form is prepopulated
|
||||||
|
if self.anything_else is not None:
|
||||||
|
self.has_anything_else_text = self.anything_else != ""
|
||||||
|
|
||||||
|
# This check is required to ensure that the form doesn't start out checked.
|
||||||
|
if self.has_anything_else_text is not None:
|
||||||
|
self.has_anything_else_text = self.anything_else != "" and self.anything_else is not None
|
||||||
|
|
||||||
def sync_organization_type(self):
|
def sync_organization_type(self):
|
||||||
"""
|
"""
|
||||||
Updates the organization_type (without saving) to match
|
Updates the organization_type (without saving) to match
|
||||||
|
@ -289,6 +316,7 @@ class DomainInformation(TimeStampedModel):
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
"""Save override for custom properties"""
|
"""Save override for custom properties"""
|
||||||
|
self.sync_yes_no_form_fields()
|
||||||
self.sync_organization_type()
|
self.sync_organization_type()
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -554,19 +554,24 @@ class DomainRequest(TimeStampedModel):
|
||||||
"""Some yes/no forms use a db field to track whether it was checked or not.
|
"""Some yes/no forms use a db field to track whether it was checked or not.
|
||||||
We handle that here for def save().
|
We handle that here for def save().
|
||||||
"""
|
"""
|
||||||
|
logger.debug("\033[91m .....syncing form...... \033[0m") # TODO-nl: delete me!
|
||||||
# This ensures that if we have prefilled data, the form is prepopulated
|
# This ensures that if we have prefilled data, the form is prepopulated
|
||||||
if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None:
|
if self.cisa_representative_first_name is not None or self.cisa_representative_last_name is not None:
|
||||||
|
logger.debug("\033[91m --> NO NONES \033[0m") # TODO-nl: delete me!
|
||||||
self.has_cisa_representative = (
|
self.has_cisa_representative = (
|
||||||
self.cisa_representative_first_name != "" and self.cisa_representative_last_name != ""
|
self.cisa_representative_first_name != "" and self.cisa_representative_last_name != ""
|
||||||
)
|
)
|
||||||
|
|
||||||
# This check is required to ensure that the form doesn't start out checked
|
# This check is required to ensure that the form doesn't start out checked
|
||||||
if self.has_cisa_representative is not None:
|
if self.has_cisa_representative is not None:
|
||||||
|
logger.debug("\033[91m --> cisa_rep is not none \033[0m") # TODO-nl: delete me!
|
||||||
self.has_cisa_representative = (
|
self.has_cisa_representative = (
|
||||||
self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None
|
self.cisa_representative_first_name != "" and self.cisa_representative_first_name is not None
|
||||||
) and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None)
|
) and (self.cisa_representative_last_name != "" and self.cisa_representative_last_name is not None)
|
||||||
|
|
||||||
|
logger.debug("\033[91m") # TODO-nl: delete me!
|
||||||
|
logger.debug(f" --> has_cisa_rep is = {self.has_cisa_representative}!") # TODO-nl: delete me!
|
||||||
|
logger.debug("\033[0m") # TODO-nl: delete me!
|
||||||
# This ensures that if we have prefilled data, the form is prepopulated
|
# This ensures that if we have prefilled data, the form is prepopulated
|
||||||
if self.anything_else is not None:
|
if self.anything_else is not None:
|
||||||
self.has_anything_else_text = self.anything_else != ""
|
self.has_anything_else_text = self.anything_else != ""
|
||||||
|
@ -920,10 +925,20 @@ class DomainRequest(TimeStampedModel):
|
||||||
def has_additional_details(self) -> bool:
|
def has_additional_details(self) -> bool:
|
||||||
"""Combines the has_anything_else_text and has_cisa_representative fields,
|
"""Combines the has_anything_else_text and has_cisa_representative fields,
|
||||||
then returns if this domain request has either of them."""
|
then returns if this domain request has either of them."""
|
||||||
|
|
||||||
# Split out for linter
|
# Split out for linter
|
||||||
has_details = False
|
has_details = True
|
||||||
if self.has_anything_else_text or self.has_cisa_representative:
|
|
||||||
has_details = True
|
if self.has_anything_else_text is None or self.has_cisa_representative is None:
|
||||||
|
has_details = False
|
||||||
|
|
||||||
|
logger.debug("\033[91m ******** Has additional ********") # TODO-nl: delete me!
|
||||||
|
logger.debug(f"""VALUE: {has_details}
|
||||||
|
|
||||||
|
DETAILS:
|
||||||
|
has_anything_else_text = {self.has_anything_else_text}
|
||||||
|
has_cisa_representative = {self.has_cisa_representative}""") # TODO-nl: delete me!
|
||||||
|
logger.debug("\033[91m ****************") # TODO-nl: delete me!
|
||||||
|
|
||||||
return has_details
|
return has_details
|
||||||
|
|
||||||
|
@ -1036,7 +1051,13 @@ class DomainRequest(TimeStampedModel):
|
||||||
def _cisa_rep_check(self):
|
def _cisa_rep_check(self):
|
||||||
# Either does not have a CISA rep, OR has a CISA rep + both first name
|
# 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
|
# and last name are NOT empty and are NOT an empty string
|
||||||
return (
|
logger.debug("\033[91m ******** CISA REP CHECK 2 ********") # TODO-nl: delete me!
|
||||||
|
logger.debug(F"""values:
|
||||||
|
has_cisa_representative = {self.has_cisa_representative}
|
||||||
|
cisa_representative_first_name = {self.cisa_representative_first_name}
|
||||||
|
cisa_representative_last_name = {self.cisa_representative_last_name}""") # TODO-nl: delete me!
|
||||||
|
logger.debug("\033[0m") # TODO-nl: delete me!
|
||||||
|
to_return = (
|
||||||
self.has_cisa_representative is True
|
self.has_cisa_representative is True
|
||||||
and self.cisa_representative_first_name is not None
|
and self.cisa_representative_first_name is not None
|
||||||
and self.cisa_representative_first_name != ""
|
and self.cisa_representative_first_name != ""
|
||||||
|
@ -1044,6 +1065,9 @@ class DomainRequest(TimeStampedModel):
|
||||||
and self.cisa_representative_last_name != ""
|
and self.cisa_representative_last_name != ""
|
||||||
) or self.has_cisa_representative is False
|
) or self.has_cisa_representative is False
|
||||||
|
|
||||||
|
logger.debug(f"RETURNING: {to_return}") # TODO-nl: delete me!
|
||||||
|
return to_return
|
||||||
|
|
||||||
def _anything_else_radio_button_and_text_field_check(self):
|
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
|
# Anything else boolean is True + filled text field and it's not an empty string OR the boolean is No
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -157,29 +157,33 @@
|
||||||
|
|
||||||
{% if step == Step.ADDITIONAL_DETAILS %}
|
{% if step == Step.ADDITIONAL_DETAILS %}
|
||||||
{% namespaced_url 'domain-request' step as domain_request_url %}
|
{% namespaced_url 'domain-request' step as domain_request_url %}
|
||||||
{% with title=form_titles|get_item:step value=domain_request.requested_domain.has_additional_details %}
|
{% with title=form_titles|get_item:step %}
|
||||||
{% include "includes/summary_item.html" with title="Additional Details" value=" " heading_level=heading_level editable=True edit_link=domain_request_url %}
|
{% if domain_request.has_additional_details %}
|
||||||
<h3 class="register-form-review-header">CISA Regional Representative</h3>
|
{% include "includes/summary_item.html" with title="Additional Details" value=" " heading_level=heading_level editable=True edit_link=domain_request_url %}
|
||||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
<h3 class="register-form-review-header">CISA Regional Representative</h3>
|
||||||
{% if domain_request.cisa_representative_first_name %}
|
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||||
{{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}
|
{% if domain_request.cisa_representative_first_name %}
|
||||||
{% if domain_request.cisa_representative_email %}
|
<li>{{domain_request.cisa_representative_first_name}} {{domain_request.cisa_representative_last_name}}</li>
|
||||||
{{domain_request.cisa_representative_email}}
|
{% if domain_request.cisa_representative_email %}
|
||||||
|
<li>{{domain_request.cisa_representative_email}}</li>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
No
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% else %}
|
</ul>
|
||||||
No
|
|
||||||
{% endif %}
|
|
||||||
</ul>
|
|
||||||
{% endwith %}
|
|
||||||
|
|
||||||
<h3 class="register-form-review-header">Anything else</h3>
|
<h3 class="register-form-review-header">Anything else</h3>
|
||||||
<ul class="usa-list usa-list--unstyled margin-top-0">
|
<ul class="usa-list usa-list--unstyled margin-top-0">
|
||||||
{% if domain_request.anything_else %}
|
{% if domain_request.anything_else %}
|
||||||
{{domain_request.anything_else}}
|
{{domain_request.anything_else}}
|
||||||
{% else %}
|
{% else %}
|
||||||
No
|
No
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
{% include "includes/summary_item.html" with title="Additional Details" value="<span class='text-bold text-secondary-dark'>Incomplete</span>"|safe heading_level=heading_level editable=True edit_link=domain_request_url %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue