mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-23 11:16:07 +02:00
Add custom errors for authorizing official
This commit is contained in:
parent
cd6809c9f7
commit
d2e6e083f3
3 changed files with 23 additions and 1 deletions
|
@ -5,6 +5,7 @@ from .domain import (
|
|||
DomainSecurityEmailForm,
|
||||
DomainOrgNameAddressForm,
|
||||
ContactForm,
|
||||
AuthorizingOfficialContactForm,
|
||||
DomainDnssecForm,
|
||||
DomainDsdataFormset,
|
||||
DomainDsdataForm,
|
||||
|
|
|
@ -148,6 +148,9 @@ class ContactForm(forms.ModelForm):
|
|||
for field_name in self.required:
|
||||
self.fields[field_name].required = True
|
||||
|
||||
# Set custom form label
|
||||
self.fields["middle_name"].label = "Middle name (optional)"
|
||||
|
||||
# Set custom error messages
|
||||
self.fields["first_name"].error_messages = {'required': 'Enter your first name / given name.'}
|
||||
self.fields["last_name"].error_messages = {'required': 'Enter your last name / family name.'}
|
||||
|
@ -159,6 +162,23 @@ class ContactForm(forms.ModelForm):
|
|||
}
|
||||
self.fields["phone"].error_messages = {'required': 'Enter your phone number.'}
|
||||
|
||||
class AuthorizingOfficialContactForm(ContactForm):
|
||||
"""Form for updating authorizing official contacts."""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Set custom error messages
|
||||
self.fields["first_name"].error_messages = {'required': 'Enter the first name / given name of this contact.'}
|
||||
self.fields["last_name"].error_messages = {'required': 'Enter the last name / family name of this contact.'}
|
||||
self.fields["title"].error_messages = {
|
||||
'required': 'Enter the title or role in your organization of this contact \
|
||||
(e.g., Chief Information Officer).'
|
||||
}
|
||||
self.fields["email"].error_messages = {
|
||||
'required': 'Enter an email address in the required format, like name@example.com.'
|
||||
}
|
||||
self.fields["phone"].error_messages = {'required': 'Enter a phone number for this contact.'}
|
||||
|
||||
|
||||
class DomainSecurityEmailForm(forms.Form):
|
||||
"""Form for adding or editing a security email to a domain."""
|
||||
|
|
|
@ -33,6 +33,7 @@ from registrar.models.utility.contact_error import ContactError
|
|||
|
||||
from ..forms import (
|
||||
ContactForm,
|
||||
AuthorizingOfficialContactForm,
|
||||
DomainOrgNameAddressForm,
|
||||
DomainAddUserForm,
|
||||
DomainSecurityEmailForm,
|
||||
|
@ -182,7 +183,7 @@ class DomainAuthorizingOfficialView(DomainFormBaseView):
|
|||
model = Domain
|
||||
template_name = "domain_authorizing_official.html"
|
||||
context_object_name = "domain"
|
||||
form_class = ContactForm
|
||||
form_class = AuthorizingOfficialContactForm
|
||||
|
||||
def get_form_kwargs(self, *args, **kwargs):
|
||||
"""Add domain_info.authorizing_official instance to make a bound form."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue