mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Add correct error messages, allow default state to be none
This commit is contained in:
parent
7e7919691e
commit
03be457e37
4 changed files with 77 additions and 13 deletions
|
@ -647,6 +647,15 @@ class DomainRequest(TimeStampedModel):
|
|||
verbose_name="Additional details",
|
||||
)
|
||||
|
||||
# This is a drop-in replacement for a has_anything_else_text() function.
|
||||
# In order to track if the user has clicked the yes/no field (while keeping a none default), we need
|
||||
# a tertiary state. We should not display this in /admin.
|
||||
has_anything_else_text = models.BooleanField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Determines if the user has a anything_else or not",
|
||||
)
|
||||
|
||||
cisa_representative_email = models.EmailField(
|
||||
null=True,
|
||||
blank=True,
|
||||
|
@ -655,6 +664,15 @@ class DomainRequest(TimeStampedModel):
|
|||
max_length=320,
|
||||
)
|
||||
|
||||
# This is a drop-in replacement for an has_cisa_representative() function.
|
||||
# In order to track if the user has clicked the yes/no field (while keeping a none default), we need
|
||||
# a tertiary state. We should not display this in /admin.
|
||||
has_cisa_representative = models.BooleanField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Determines if the user has a representative email or not",
|
||||
)
|
||||
|
||||
is_policy_acknowledged = models.BooleanField(
|
||||
null=True,
|
||||
blank=True,
|
||||
|
@ -707,8 +725,25 @@ class DomainRequest(TimeStampedModel):
|
|||
def save(self, *args, **kwargs):
|
||||
"""Save override for custom properties"""
|
||||
self.sync_organization_type()
|
||||
self.sync_yes_no_form_fields()
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
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().
|
||||
"""
|
||||
# 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
|
||||
)
|
||||
|
||||
if self.anything_else is not None:
|
||||
self.has_anything_else_text = (
|
||||
self.anything_else != "" and self.anything_else is not None
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
try:
|
||||
if self.requested_domain and self.requested_domain.name:
|
||||
|
@ -1047,16 +1082,8 @@ class DomainRequest(TimeStampedModel):
|
|||
"""Does this domain request have other contacts listed?"""
|
||||
return self.other_contacts.exists()
|
||||
|
||||
def has_anything_else_text(self) -> bool:
|
||||
"""Does this domain request have an 'anything else?' entry"""
|
||||
return self.anything_else != "" and self.anything_else is not None
|
||||
|
||||
def has_cisa_representative(self) -> bool:
|
||||
"""Does this domain request have cisa representative?"""
|
||||
return self.cisa_representative_email != "" and self.cisa_representative_email is not None
|
||||
|
||||
def has_additional_details(self) -> bool:
|
||||
return self.has_anything_else_text() or self.has_cisa_representative()
|
||||
return self.has_anything_else_text() or self.has_cisa_representative
|
||||
|
||||
def is_federal(self) -> Union[bool, None]:
|
||||
"""Is this domain request for a federal agency?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue