From e4c83751bfbc7cc0d2f0fc508f225104ffba4dd3 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:23:02 -0600 Subject: [PATCH 01/14] Fix bug --- src/registrar/forms/domain.py | 25 +++++++++++++++++-- src/registrar/forms/domain_request_wizard.py | 24 ++++++++++++++++++ .../templates/includes/input_with_errors.html | 2 +- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 0bfd9b667..0130bd3fd 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -15,7 +15,7 @@ from registrar.utility.errors import ( SecurityEmailError, SecurityEmailErrorCodes, ) - +from django.core.validators import RegexValidator, MaxLengthValidator from ..models import Contact, DomainInformation, Domain from .common import ( ALGORITHM_CHOICES, @@ -31,7 +31,18 @@ logger = logging.getLogger(__name__) class DomainAddUserForm(forms.Form): """Form for adding a user to a domain.""" - email = forms.EmailField(label="Email") + email = forms.EmailField( + label="Email", + max_length=254, + error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, + # This validator should exist in the event that a preexisting field is of invalid length + validators=[ + MaxLengthValidator( + 254, + message="Response must be less than 254 characters.", + ) + ], + ) def clean(self): """clean form data by lowercasing email""" @@ -193,6 +204,8 @@ class ContactForm(forms.ModelForm): # take off maxlength attribute for the phone number field # which interferes with out input_with_errors template tag self.fields["phone"].widget.attrs.pop("maxlength", None) + max = self.fields["email"].widget.attrs["maxlength"] + print(f"what is the max? {max}") for field_name in self.required: self.fields[field_name].required = True @@ -291,10 +304,18 @@ class DomainSecurityEmailForm(forms.Form): security_email = forms.EmailField( label="Security email (optional)", + max_length=254, required=False, error_messages={ "invalid": str(SecurityEmailError(code=SecurityEmailErrorCodes.BAD_DATA)), }, + # This validator should exist in the event that a preexisting field is of invalid length + validators=[ + MaxLengthValidator( + 254, + message="Response must be less than 254 characters.", + ) + ], ) diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index 1efc028f6..8ef0f6e33 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -369,7 +369,15 @@ class AuthorizingOfficialForm(RegistrarForm): ) email = forms.EmailField( label="Email", + max_length=254, error_messages={"invalid": ("Enter an email address in the required format, like name@example.com.")}, + # This validator should exist in the event that a preexisting field is of invalid length + validators=[ + MaxLengthValidator( + 254, + message="Response must be less than 254 characters.", + ) + ], ) @@ -566,7 +574,15 @@ class YourContactForm(RegistrarForm): ) email = forms.EmailField( label="Email", + max_length=254, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, + # This validator should exist in the event that a preexisting field is of invalid length + validators=[ + MaxLengthValidator( + 254, + message="Response must be less than 254 characters.", + ) + ], ) phone = PhoneNumberField( label="Phone", @@ -621,10 +637,18 @@ class OtherContactsForm(RegistrarForm): ) email = forms.EmailField( label="Email", + max_length=254, error_messages={ "required": ("Enter an email address in the required format, like name@example.com."), "invalid": ("Enter an email address in the required format, like name@example.com."), }, + # This validator should exist in the event that a preexisting field is of invalid length + validators=[ + MaxLengthValidator( + 254, + message="Response must be less than 254 characters.", + ) + ], ) phone = PhoneNumberField( label="Phone", diff --git a/src/registrar/templates/includes/input_with_errors.html b/src/registrar/templates/includes/input_with_errors.html index 56bd0b111..24308741d 100644 --- a/src/registrar/templates/includes/input_with_errors.html +++ b/src/registrar/templates/includes/input_with_errors.html @@ -76,7 +76,7 @@ error messages, if necessary. {% endif %} -{% if widget.attrs.maxlength %} +{% if widget.attrs.maxlength and show_max_length %} Date: Wed, 3 Apr 2024 15:26:05 -0600 Subject: [PATCH 02/14] Cleanup --- src/registrar/forms/domain.py | 6 ++---- .../templates/includes/input_with_errors.html | 12 ------------ 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 0130bd3fd..1a6a8778e 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -2,7 +2,7 @@ import logging from django import forms -from django.core.validators import MinValueValidator, MaxValueValidator, RegexValidator +from django.core.validators import MinValueValidator, MaxValueValidator, RegexValidator, MaxLengthValidator from django.forms import formset_factory from registrar.models import DomainRequest from phonenumber_field.widgets import RegionalPhoneNumberWidget @@ -15,7 +15,7 @@ from registrar.utility.errors import ( SecurityEmailError, SecurityEmailErrorCodes, ) -from django.core.validators import RegexValidator, MaxLengthValidator + from ..models import Contact, DomainInformation, Domain from .common import ( ALGORITHM_CHOICES, @@ -204,8 +204,6 @@ class ContactForm(forms.ModelForm): # take off maxlength attribute for the phone number field # which interferes with out input_with_errors template tag self.fields["phone"].widget.attrs.pop("maxlength", None) - max = self.fields["email"].widget.attrs["maxlength"] - print(f"what is the max? {max}") for field_name in self.required: self.fields[field_name].required = True diff --git a/src/registrar/templates/includes/input_with_errors.html b/src/registrar/templates/includes/input_with_errors.html index 24308741d..b6c24ba3e 100644 --- a/src/registrar/templates/includes/input_with_errors.html +++ b/src/registrar/templates/includes/input_with_errors.html @@ -75,15 +75,3 @@ error messages, if necessary. {% else %} {% endif %} - -{% if widget.attrs.maxlength and show_max_length %} - - You can enter up to {{ widget.attrs.maxlength }} characters - - - -{% endif %} From d8777c5dae698d808acab0ca7596f4dd70933020 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Wed, 3 Apr 2024 15:44:57 -0600 Subject: [PATCH 03/14] Fix javascript errors --- .../templates/includes/input_with_errors.html | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/registrar/templates/includes/input_with_errors.html b/src/registrar/templates/includes/input_with_errors.html index b6c24ba3e..e189f8d85 100644 --- a/src/registrar/templates/includes/input_with_errors.html +++ b/src/registrar/templates/includes/input_with_errors.html @@ -75,3 +75,25 @@ error messages, if necessary. {% else %} {% endif %} + +{% if widget.attrs.maxlength %} + + + +{% endif %} From df3e628e613ed885fb382c0bac176b1c646b2d62 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:33:18 -0600 Subject: [PATCH 04/14] Remove max length --- src/registrar/forms/domain.py | 4 ---- src/registrar/forms/domain_request_wizard.py | 6 ------ 2 files changed, 10 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 1a6a8778e..0d135c58b 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -33,9 +33,7 @@ class DomainAddUserForm(forms.Form): email = forms.EmailField( label="Email", - max_length=254, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, - # This validator should exist in the event that a preexisting field is of invalid length validators=[ MaxLengthValidator( 254, @@ -302,12 +300,10 @@ class DomainSecurityEmailForm(forms.Form): security_email = forms.EmailField( label="Security email (optional)", - max_length=254, required=False, error_messages={ "invalid": str(SecurityEmailError(code=SecurityEmailErrorCodes.BAD_DATA)), }, - # This validator should exist in the event that a preexisting field is of invalid length validators=[ MaxLengthValidator( 254, diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index 8ef0f6e33..9ac17b145 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -369,9 +369,7 @@ class AuthorizingOfficialForm(RegistrarForm): ) email = forms.EmailField( label="Email", - max_length=254, error_messages={"invalid": ("Enter an email address in the required format, like name@example.com.")}, - # This validator should exist in the event that a preexisting field is of invalid length validators=[ MaxLengthValidator( 254, @@ -574,9 +572,7 @@ class YourContactForm(RegistrarForm): ) email = forms.EmailField( label="Email", - max_length=254, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, - # This validator should exist in the event that a preexisting field is of invalid length validators=[ MaxLengthValidator( 254, @@ -637,12 +633,10 @@ class OtherContactsForm(RegistrarForm): ) email = forms.EmailField( label="Email", - max_length=254, error_messages={ "required": ("Enter an email address in the required format, like name@example.com."), "invalid": ("Enter an email address in the required format, like name@example.com."), }, - # This validator should exist in the event that a preexisting field is of invalid length validators=[ MaxLengthValidator( 254, From 1e4be56e8ebb62d6bb1fa5b363b11ef28577de5e Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Apr 2024 08:40:40 -0600 Subject: [PATCH 05/14] 254 -> 320 characters --- src/registrar/forms/domain.py | 8 ++++---- src/registrar/forms/domain_request_wizard.py | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 0d135c58b..12417c0d2 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -36,8 +36,8 @@ class DomainAddUserForm(forms.Form): error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, validators=[ MaxLengthValidator( - 254, - message="Response must be less than 254 characters.", + 320, + message="Response must be less than 320 characters.", ) ], ) @@ -306,8 +306,8 @@ class DomainSecurityEmailForm(forms.Form): }, validators=[ MaxLengthValidator( - 254, - message="Response must be less than 254 characters.", + 320, + message="Response must be less than 320 characters.", ) ], ) diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index 9ac17b145..1e8034fe2 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -372,8 +372,8 @@ class AuthorizingOfficialForm(RegistrarForm): error_messages={"invalid": ("Enter an email address in the required format, like name@example.com.")}, validators=[ MaxLengthValidator( - 254, - message="Response must be less than 254 characters.", + 320, + message="Response must be less than 320 characters.", ) ], ) @@ -575,8 +575,8 @@ class YourContactForm(RegistrarForm): error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, validators=[ MaxLengthValidator( - 254, - message="Response must be less than 254 characters.", + 320, + message="Response must be less than 320 characters.", ) ], ) @@ -639,8 +639,8 @@ class OtherContactsForm(RegistrarForm): }, validators=[ MaxLengthValidator( - 254, - message="Response must be less than 254 characters.", + 320, + message="Response must be less than 320 characters.", ) ], ) From 6728826c0b69e84cbe53025572d8ae5eb45f735c Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:37:36 -0600 Subject: [PATCH 06/14] Fix max length bug --- src/registrar/forms/domain.py | 2 ++ src/registrar/forms/domain_request_wizard.py | 3 +++ .../templates/includes/input_with_errors.html | 12 +----------- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/registrar/forms/domain.py b/src/registrar/forms/domain.py index 12417c0d2..faf21e12e 100644 --- a/src/registrar/forms/domain.py +++ b/src/registrar/forms/domain.py @@ -33,6 +33,7 @@ class DomainAddUserForm(forms.Form): email = forms.EmailField( label="Email", + max_length=None, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, validators=[ MaxLengthValidator( @@ -300,6 +301,7 @@ class DomainSecurityEmailForm(forms.Form): security_email = forms.EmailField( label="Security email (optional)", + max_length=None, required=False, error_messages={ "invalid": str(SecurityEmailError(code=SecurityEmailErrorCodes.BAD_DATA)), diff --git a/src/registrar/forms/domain_request_wizard.py b/src/registrar/forms/domain_request_wizard.py index 1e8034fe2..c3ac3b4c2 100644 --- a/src/registrar/forms/domain_request_wizard.py +++ b/src/registrar/forms/domain_request_wizard.py @@ -369,6 +369,7 @@ class AuthorizingOfficialForm(RegistrarForm): ) email = forms.EmailField( label="Email", + max_length=None, error_messages={"invalid": ("Enter an email address in the required format, like name@example.com.")}, validators=[ MaxLengthValidator( @@ -572,6 +573,7 @@ class YourContactForm(RegistrarForm): ) email = forms.EmailField( label="Email", + max_length=None, error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")}, validators=[ MaxLengthValidator( @@ -633,6 +635,7 @@ class OtherContactsForm(RegistrarForm): ) email = forms.EmailField( label="Email", + max_length=None, error_messages={ "required": ("Enter an email address in the required format, like name@example.com."), "invalid": ("Enter an email address in the required format, like name@example.com."), diff --git a/src/registrar/templates/includes/input_with_errors.html b/src/registrar/templates/includes/input_with_errors.html index e189f8d85..56bd0b111 100644 --- a/src/registrar/templates/includes/input_with_errors.html +++ b/src/registrar/templates/includes/input_with_errors.html @@ -79,17 +79,7 @@ error messages, if necessary. {% if widget.attrs.maxlength %}