mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-09 22:14:43 +02:00
Respond to PR feedback
This commit is contained in:
parent
456cab6cee
commit
b3784776d7
22 changed files with 54 additions and 62 deletions
|
@ -416,6 +416,7 @@ CurrentSitesFormSet = forms.formset_factory(
|
|||
formset=BaseCurrentSitesFormSet,
|
||||
)
|
||||
|
||||
|
||||
class AlternativeDomainForm(RegistrarForm):
|
||||
def clean_alternative_domain(self):
|
||||
"""Validation code for domain names."""
|
||||
|
@ -423,19 +424,23 @@ class AlternativeDomainForm(RegistrarForm):
|
|||
requested = self.cleaned_data.get("alternative_domain", None)
|
||||
validated = Domain.validate(requested, blank_ok=True)
|
||||
except errors.ExtraDotsError:
|
||||
raise forms.ValidationError(code="extra_dots")
|
||||
raise forms.ValidationError(
|
||||
DOMAIN_API_MESSAGES["extra_dots"], code="extra_dots"
|
||||
)
|
||||
except errors.DomainUnavailableError:
|
||||
raise forms.ValidationError(code="unavailable")
|
||||
raise forms.ValidationError(
|
||||
DOMAIN_API_MESSAGES["unavailable"], code="unavailable"
|
||||
)
|
||||
except ValueError:
|
||||
raise forms.ValidationError(code="invalid")
|
||||
raise forms.ValidationError(DOMAIN_API_MESSAGES["invalid"], code="invalid")
|
||||
return validated
|
||||
|
||||
alternative_domain = forms.CharField(
|
||||
required=False,
|
||||
label="Alternative domain",
|
||||
error_messages=DOMAIN_API_MESSAGES
|
||||
)
|
||||
|
||||
|
||||
class BaseAlternativeDomainFormSet(RegistrarFormSet):
|
||||
JOIN = "alternative_domains"
|
||||
|
||||
|
@ -508,19 +513,22 @@ class DotGovDomainForm(RegistrarForm):
|
|||
requested = self.cleaned_data.get("requested_domain", None)
|
||||
validated = Domain.validate(requested)
|
||||
except errors.BlankValueError:
|
||||
raise forms.ValidationError(code="required")
|
||||
raise forms.ValidationError(
|
||||
DOMAIN_API_MESSAGES["required"], code="required"
|
||||
)
|
||||
except errors.ExtraDotsError:
|
||||
raise forms.ValidationError(code="extra_dots")
|
||||
raise forms.ValidationError(
|
||||
DOMAIN_API_MESSAGES["extra_dots"], code="extra_dots"
|
||||
)
|
||||
except errors.DomainUnavailableError:
|
||||
raise forms.ValidationError(code="unavailable")
|
||||
raise forms.ValidationError(
|
||||
DOMAIN_API_MESSAGES["unavailable"], code="unavailable"
|
||||
)
|
||||
except ValueError:
|
||||
raise forms.ValidationError(code="invalid")
|
||||
raise forms.ValidationError(DOMAIN_API_MESSAGES["invalid"], code="invalid")
|
||||
return validated
|
||||
|
||||
requested_domain = forms.CharField(
|
||||
label="What .gov domain do you want?",
|
||||
error_messages=DOMAIN_API_MESSAGES
|
||||
)
|
||||
requested_domain = forms.CharField(label="What .gov domain do you want?")
|
||||
|
||||
|
||||
class PurposeForm(RegistrarForm):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue