mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Infra
This commit is contained in:
parent
75499337e0
commit
dd9df90fb4
5 changed files with 55 additions and 13 deletions
|
@ -1,11 +1,15 @@
|
||||||
from django import forms
|
from django import forms
|
||||||
from phonenumber_field.modelfields import PhoneNumberField # type: ignore
|
from phonenumber_field.formfields import PhoneNumberField # type: ignore
|
||||||
from django.core.validators import MaxLengthValidator
|
from django.core.validators import MaxLengthValidator
|
||||||
|
|
||||||
|
|
||||||
class ContactForm(forms.Form):
|
class ContactForm(forms.Form):
|
||||||
"""Form for adding or editing a contact"""
|
"""Form for adding or editing a contact"""
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
kwargs.setdefault("label_suffix", "")
|
||||||
|
super(ContactForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
first_name = forms.CharField(
|
first_name = forms.CharField(
|
||||||
label="First name / given name",
|
label="First name / given name",
|
||||||
error_messages={"required": "Enter your first name / given name."},
|
error_messages={"required": "Enter your first name / given name."},
|
||||||
|
|
|
@ -16,7 +16,6 @@ from registrar.forms.utility.wizard_form_helper import (
|
||||||
from registrar.models import Contact, DomainRequest, DraftDomain, Domain, FederalAgency
|
from registrar.models import Contact, DomainRequest, DraftDomain, Domain, FederalAgency
|
||||||
from registrar.templatetags.url_helpers import public_site_url
|
from registrar.templatetags.url_helpers import public_site_url
|
||||||
from registrar.utility.enums import ValidationReturnType
|
from registrar.utility.enums import ValidationReturnType
|
||||||
from registrar.forms import ContactForm
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -386,7 +385,7 @@ class PurposeForm(RegistrarForm):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class YourContactForm(RegistrarForm, ContactForm):
|
class YourContactForm(RegistrarForm):
|
||||||
JOIN = "submitter"
|
JOIN = "submitter"
|
||||||
|
|
||||||
def to_database(self, obj):
|
def to_database(self, obj):
|
||||||
|
@ -409,6 +408,40 @@ class YourContactForm(RegistrarForm, ContactForm):
|
||||||
contact = getattr(obj, "submitter", None)
|
contact = getattr(obj, "submitter", None)
|
||||||
return super().from_database(contact)
|
return super().from_database(contact)
|
||||||
|
|
||||||
|
first_name = forms.CharField(
|
||||||
|
label="First name / given name",
|
||||||
|
error_messages={"required": "Enter your first name / given name."},
|
||||||
|
)
|
||||||
|
middle_name = forms.CharField(
|
||||||
|
required=False,
|
||||||
|
label="Middle name (optional)",
|
||||||
|
)
|
||||||
|
last_name = forms.CharField(
|
||||||
|
label="Last name / family name",
|
||||||
|
error_messages={"required": "Enter your last name / family name."},
|
||||||
|
)
|
||||||
|
title = forms.CharField(
|
||||||
|
label="Title or role in your organization",
|
||||||
|
error_messages={
|
||||||
|
"required": ("Enter your title or role in your organization (e.g., Chief Information Officer).")
|
||||||
|
},
|
||||||
|
)
|
||||||
|
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(
|
||||||
|
320,
|
||||||
|
message="Response must be less than 320 characters.",
|
||||||
|
)
|
||||||
|
],
|
||||||
|
)
|
||||||
|
phone = PhoneNumberField(
|
||||||
|
label="Phone",
|
||||||
|
error_messages={"invalid": "Enter a valid 10-digit phone number.", "required": "Enter your phone number."},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class OtherContactsYesNoForm(BaseYesNoForm):
|
class OtherContactsYesNoForm(BaseYesNoForm):
|
||||||
"""The yes/no field for the OtherContacts form."""
|
"""The yes/no field for the OtherContacts form."""
|
||||||
|
|
|
@ -23,9 +23,6 @@ class RegistrarForm(forms.Form):
|
||||||
# save a reference to a domain request object
|
# save a reference to a domain request object
|
||||||
if "domain_request" in kwargs:
|
if "domain_request" in kwargs:
|
||||||
self.domain_request = kwargs.pop("domain_request", None)
|
self.domain_request = kwargs.pop("domain_request", None)
|
||||||
|
|
||||||
if "contact" in kwargs:
|
|
||||||
self.contact = kwargs.pop("contact", None)
|
|
||||||
|
|
||||||
super(RegistrarForm, self).__init__(*args, **kwargs)
|
super(RegistrarForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -41,20 +41,22 @@
|
||||||
<legend class="usa-sr-only">
|
<legend class="usa-sr-only">
|
||||||
Your contact information
|
Your contact information
|
||||||
</legend>
|
</legend>
|
||||||
|
{{form.first_name}}
|
||||||
{% input_with_errors forms.0.first_name %}
|
{% comment %}
|
||||||
|
{% input_with_errors form.first_name %}
|
||||||
|
|
||||||
{% input_with_errors forms.0.middle_name %}
|
{% input_with_errors form.middle_name %}
|
||||||
|
|
||||||
{% input_with_errors forms.0.last_name %}
|
{% input_with_errors form.last_name %}
|
||||||
|
|
||||||
{% input_with_errors forms.0.title %}
|
{% input_with_errors form.title %}
|
||||||
|
|
||||||
{% input_with_errors forms.0.email %}
|
{% input_with_errors form.email %}
|
||||||
|
|
||||||
{% with add_class="usa-input--medium" %}
|
{% with add_class="usa-input--medium" %}
|
||||||
{% input_with_errors forms.0.phone %}
|
{% input_with_errors form.phone %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
|
{% endcomment %}
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
@ -75,6 +75,12 @@ class ContactProfileSetupView(ContactPermissionView):
|
||||||
template_name = "finish_contact_setup.html"
|
template_name = "finish_contact_setup.html"
|
||||||
form_class = ContactForm
|
form_class = ContactForm
|
||||||
|
|
||||||
|
def get_form_kwargs(self, *args, **kwargs):
|
||||||
|
"""Add domain_info.organization_name instance to make a bound form."""
|
||||||
|
form_kwargs = super().get_form_kwargs(*args, **kwargs)
|
||||||
|
form_kwargs["instance"] = self.object
|
||||||
|
return form_kwargs
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
self._get_contact(request)
|
self._get_contact(request)
|
||||||
context = self.get_context_data(object=self.object)
|
context = self.get_context_data(object=self.object)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue