Fixed form state check

This commit is contained in:
CocoByte 2024-05-19 15:39:00 -06:00
parent 377cb30818
commit c5b841f6fb
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
2 changed files with 5 additions and 4 deletions

View file

@ -685,9 +685,9 @@ class CisaRepresentativeForm(BaseDeletableRegistrarForm):
email = forms.EmailField(
label="Email",
max_length=None,
required=False,
error_messages={
"invalid": ("Enter your email address in the required format, like name@example.com."),
"required": ("Enter the email address of your CISA regional representative."),
},
validators=[
MaxLengthValidator(

View file

@ -538,15 +538,16 @@ class DomainRequest(TimeStampedModel):
"""
cisa_rep_is_not_none = self.cisa_representative is not None
logger.debug("CISA REPRESENTATIVE IS %s" % cisa_rep_is_not_none)
cisa_first_name = None
# This ensures that if we have prefilled data, the form is prepopulated
if cisa_rep_is_not_none:
self.has_cisa_representative = True
cisa_first_name = self.cisa_representative.first_name
self.has_cisa_representative = cisa_first_name is not None and cisa_first_name != ""
# This check is required to ensure that the form doesn't start out checked
if self.has_cisa_representative is not None:
self.has_cisa_representative = cisa_rep_is_not_none
self.has_cisa_representative = cisa_first_name is not None and cisa_first_name != ""
# This ensures that if we have prefilled data, the form is prepopulated
if self.anything_else is not None: