mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Linted
This commit is contained in:
parent
81f6e3e389
commit
44c74c7c86
3 changed files with 25 additions and 13 deletions
|
@ -778,9 +778,11 @@ OtherContactsFormSet = forms.formset_factory(
|
|||
formset=BaseOtherContactsFormSet,
|
||||
)
|
||||
|
||||
|
||||
class BaseDeletableRegistrarForm(RegistrarForm):
|
||||
"""Adds special validation and delete functionality.
|
||||
Used by forms that are tied to a Yes/No form."""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.form_data_marked_for_deletion = False
|
||||
super().__init__(*args, **kwargs)
|
||||
|
@ -830,6 +832,7 @@ class BaseDeletableRegistrarForm(RegistrarForm):
|
|||
setattr(obj, name, value)
|
||||
obj.save()
|
||||
|
||||
|
||||
class NoOtherContactsForm(BaseDeletableRegistrarForm):
|
||||
no_other_contacts_rationale = forms.CharField(
|
||||
required=True,
|
||||
|
@ -845,12 +848,14 @@ class NoOtherContactsForm(BaseDeletableRegistrarForm):
|
|||
error_messages={"required": ("Rationale for no other employees is required.")},
|
||||
)
|
||||
|
||||
|
||||
class CisaRepresentativeForm(BaseDeletableRegistrarForm):
|
||||
cisa_representative_email = forms.EmailField(
|
||||
required=False,
|
||||
label="Are you working with a CISA representative?", # TODO-NL: (design check) - is this the right label?
|
||||
)
|
||||
|
||||
|
||||
class CisaRepresentativeYesNoForm(RegistrarForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Extend the initialization of the form from RegistrarForm __init__"""
|
||||
|
@ -889,6 +894,7 @@ class AdditionalDetailsForm(BaseDeletableRegistrarForm):
|
|||
],
|
||||
)
|
||||
|
||||
|
||||
class AdditionalDetailsYesNoForm(RegistrarForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
"""Extend the initialization of the form from RegistrarForm __init__"""
|
||||
|
@ -913,6 +919,7 @@ class AdditionalDetailsYesNoForm(RegistrarForm):
|
|||
},
|
||||
)
|
||||
|
||||
|
||||
class RequirementsForm(RegistrarForm):
|
||||
is_policy_acknowledged = forms.BooleanField(
|
||||
label="I read and agree to the requirements for operating a .gov domain.",
|
||||
|
|
|
@ -1040,11 +1040,11 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
def has_anything_else_text(self) -> bool:
|
||||
"""Does this domain request have an 'anything else?' entry"""
|
||||
return self.anything_else != "" and self.anything_else != None #TODO-NL: how to handle falsy strings again?
|
||||
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 != None
|
||||
return self.cisa_representative_email != "" and self.cisa_representative_email is not None
|
||||
|
||||
def is_federal(self) -> Union[bool, None]:
|
||||
"""Is this domain request for a federal agency?
|
||||
|
|
|
@ -366,7 +366,8 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
or self.domain_request.no_other_contacts_rationale is not None
|
||||
),
|
||||
"anything_else": (
|
||||
(self.domain_request.anything_else is not None and self.domain_request.cisa_representative_email) or self.domain_request.is_policy_acknowledged is not None
|
||||
(self.domain_request.anything_else is not None and self.domain_request.cisa_representative_email)
|
||||
or self.domain_request.is_policy_acknowledged is not None
|
||||
),
|
||||
"requirements": self.domain_request.is_policy_acknowledged is not None,
|
||||
"review": self.domain_request.is_policy_acknowledged is not None,
|
||||
|
@ -580,6 +581,7 @@ class OtherContacts(DomainRequestWizard):
|
|||
all_forms_valid = False
|
||||
return all_forms_valid
|
||||
|
||||
|
||||
# DONE-NL: rename this to "Additional Details" (note: this is a find-replace job. VS will not refactor properly)
|
||||
class AdditionalDetails(DomainRequestWizard):
|
||||
|
||||
|
@ -590,7 +592,12 @@ class AdditionalDetails(DomainRequestWizard):
|
|||
template_name = "domain_request_additional_details.html"
|
||||
# OLD: forms = [forms.OtherContactsYesNoForm, forms.OtherContactsFormSet, forms.NoOtherContactsForm]
|
||||
# TODO-NL: (refactor) -- move form hookups into respective areas
|
||||
forms = [forms.CisaRepresentativeYesNoForm, forms.CisaRepresentativeForm, forms.AdditionalDetailsYesNoForm, forms.AdditionalDetailsForm]
|
||||
forms = [
|
||||
forms.CisaRepresentativeYesNoForm,
|
||||
forms.CisaRepresentativeForm,
|
||||
forms.AdditionalDetailsYesNoForm,
|
||||
forms.AdditionalDetailsForm,
|
||||
]
|
||||
|
||||
# TODO-NL: (refactor) -- move validation into respective areas
|
||||
def is_valid(self, forms: list) -> bool:
|
||||
|
@ -621,7 +628,6 @@ class AdditionalDetails(DomainRequestWizard):
|
|||
cisa_representative_email_form.mark_form_for_deletion()
|
||||
cisa_rep_portion_is_valid = False
|
||||
|
||||
|
||||
# ------- Validate anything else -------
|
||||
anything_else_portion_is_valid = True
|
||||
# test first for yes_no_form validity
|
||||
|
@ -638,7 +644,6 @@ class AdditionalDetails(DomainRequestWizard):
|
|||
anything_else_form.mark_form_for_deletion()
|
||||
anything_else_portion_is_valid = False
|
||||
|
||||
|
||||
# ------- Return combined validation result -------
|
||||
all_forms_valid = cisa_rep_portion_is_valid and anything_else_portion_is_valid
|
||||
return all_forms_valid
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue