Updates to Cisa Rep fields in Additional Details. Refactored Cisa Rep to utilize ContactsModel

This commit is contained in:
CocoByte 2024-05-17 12:19:54 -06:00
parent cfce03ac8d
commit a789b34bc0
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F
5 changed files with 126 additions and 25 deletions

View file

@ -457,11 +457,14 @@ class DomainRequest(TimeStampedModel):
help_text="Determines if the user has a anything_else or not",
)
cisa_representative_email = models.EmailField(
cisa_representative = models.ForeignKey(
"registrar.Contact",
null=True,
blank=True,
verbose_name="CISA regional representative",
max_length=320,
related_name="cisa_representative_domain_requests",
on_delete=models.PROTECT,
help_text='Cisa Representative listed under "additional information" in the request form',
)
# This is a drop-in replacement for an has_cisa_representative() function.
@ -534,15 +537,16 @@ class DomainRequest(TimeStampedModel):
We handle that here for def save().
"""
cisa_rep_is_not_none = self.cisa_representative is not None
logger.debug("CISA REPRESENTATIVE IS %s" % cisa_rep_is_not_none)
# This ensures that if we have prefilled data, the form is prepopulated
if self.cisa_representative_email is not None:
self.has_cisa_representative = self.cisa_representative_email != ""
if cisa_rep_is_not_none:
self.has_cisa_representative = True
# 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 = (
self.cisa_representative_email != "" and self.cisa_representative_email is not None
)
self.has_cisa_representative = cisa_rep_is_not_none
# This ensures that if we have prefilled data, the form is prepopulated
if self.anything_else is not None: