fix linting errors

This commit is contained in:
Neil Martinsen-Burrell 2023-06-01 14:47:19 -05:00
parent 4623a5dfb2
commit d31a5aa512
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
2 changed files with 2 additions and 40 deletions

View file

@ -64,34 +64,3 @@ class DomainSecurityEmailForm(forms.Form):
"""Form for adding or editing a security email to a domain."""
security_email = forms.EmailField(label="Security email")
class ContactForm(forms.ModelForm):
"""Form for updating contacts."""
class Meta:
model = Contact
fields = ["first_name", "middle_name", "last_name", "title", "email", "phone"]
widgets = {
"first_name": forms.TextInput,
"middle_name": forms.TextInput,
"last_name": forms.TextInput,
"title": forms.TextInput,
"email": forms.EmailInput,
"phone": RegionalPhoneNumberWidget,
}
# the database fields have blank=True so ModelForm doesn't create
# required fields by default. Use this list in __init__ to mark each
# of these fields as required
required = ["first_name", "last_name", "title", "email", "phone"]
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# take off maxlength attribute for the phone number field
# which interferes with our input_with_errors template tag
self.fields["phone"].widget.attrs.pop("maxlength", None)
for field_name in self.required:
self.fields[field_name].required = True

View file

@ -281,17 +281,10 @@ class TestFormValidation(TestCase):
class TestContactForm(TestCase):
def test_contact_form_email_invalid(self):
form = ContactForm(data={"email": "example.net"})
self.assertEqual(
form.errors["email"],
["Enter a valid email address."]
)
self.assertEqual(form.errors["email"], ["Enter a valid email address."])
def test_contact_form_email_invalid2(self):
form = ContactForm(data={"email": "@"})
self.assertEqual(
form.errors["email"],
["Enter a valid email address."]
)
self.assertEqual(form.errors["email"], ["Enter a valid email address."])