mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-12 20:49:41 +02:00
Setup org name address page
This commit is contained in:
parent
d4162c5d9c
commit
162d42e647
6 changed files with 154 additions and 4 deletions
|
@ -88,6 +88,11 @@ urlpatterns = [
|
||||||
views.DomainYourContactInformationView.as_view(),
|
views.DomainYourContactInformationView.as_view(),
|
||||||
name="domain-your-contact-information",
|
name="domain-your-contact-information",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"domain/<int:pk>/org-name-address",
|
||||||
|
views.DomainOrgNameAddressView.as_view(),
|
||||||
|
name="domain-org-name-address",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"domain/<int:pk>/authorizing-official",
|
"domain/<int:pk>/authorizing-official",
|
||||||
views.DomainAuthorizingOfficialView.as_view(),
|
views.DomainAuthorizingOfficialView.as_view(),
|
||||||
|
|
|
@ -3,5 +3,6 @@ from .domain import (
|
||||||
DomainAddUserForm,
|
DomainAddUserForm,
|
||||||
NameserverFormset,
|
NameserverFormset,
|
||||||
DomainSecurityEmailForm,
|
DomainSecurityEmailForm,
|
||||||
|
DomainOrgNameAddressForm,
|
||||||
ContactForm,
|
ContactForm,
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.forms import formset_factory
|
||||||
|
|
||||||
from phonenumber_field.widgets import RegionalPhoneNumberWidget
|
from phonenumber_field.widgets import RegionalPhoneNumberWidget
|
||||||
|
|
||||||
from ..models import Contact
|
from ..models import Contact, DomainInformation
|
||||||
|
|
||||||
|
|
||||||
class DomainAddUserForm(forms.Form):
|
class DomainAddUserForm(forms.Form):
|
||||||
|
@ -64,3 +64,58 @@ class DomainSecurityEmailForm(forms.Form):
|
||||||
"""Form for adding or editing a security email to a domain."""
|
"""Form for adding or editing a security email to a domain."""
|
||||||
|
|
||||||
security_email = forms.EmailField(label="Security email")
|
security_email = forms.EmailField(label="Security email")
|
||||||
|
|
||||||
|
|
||||||
|
class DomainOrgNameAddressForm(forms.ModelForm):
|
||||||
|
|
||||||
|
"""Form for updating the organization name and mailing address."""
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
model = DomainInformation
|
||||||
|
fields = ["federal_agency", "organization_name", "address_line1", "address_line2", "city", "state_territory", "zipcode", "urbanization"]
|
||||||
|
labels = {
|
||||||
|
"address_line1": "Street address",
|
||||||
|
"address_line2": "Street address line 2",
|
||||||
|
"state_territory": "State, territory, or military post",
|
||||||
|
"urbanization": "Urbanization (Puerto Rico only)",
|
||||||
|
}
|
||||||
|
error_messages = {
|
||||||
|
"federal_agency": {"required": "Select the federal agency for your organization." },
|
||||||
|
"organization_name": {"required": "Enter the name of your organization." },
|
||||||
|
"address_line1": {"required": "Enter the street address of your organization." },
|
||||||
|
"city": {"required": "Enter the city where your organization is located."},
|
||||||
|
"state_territory": {"required": "Select the state, territory, or military post where your organization is located."},
|
||||||
|
"zipcode": {"required": "Enter a zip code in the form of 12345 or 12345-6789."},
|
||||||
|
}
|
||||||
|
widgets = {
|
||||||
|
"federal_agency": forms.Select(attrs={"required": True}, choices=DomainInformation.AGENCY_CHOICES),
|
||||||
|
"organization_name": forms.TextInput,
|
||||||
|
"address_line1": forms.TextInput,
|
||||||
|
"address_line2": forms.TextInput,
|
||||||
|
"city": forms.TextInput,
|
||||||
|
"state_territory": forms.Select(attrs={"required": True,}, choices=DomainInformation.StateTerritoryChoices.choices),
|
||||||
|
"zipcode": forms.TextInput,
|
||||||
|
"urbanization" : forms.TextInput,
|
||||||
|
}
|
||||||
|
|
||||||
|
# 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 = ["organization_name", "address_line1", "city", "zipcode"]
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
for field_name in self.required:
|
||||||
|
self.fields[field_name].required = True
|
||||||
|
self.fields["state_territory"].widget.attrs.pop("maxlength", None)
|
||||||
|
self.fields["zipcode"].widget.attrs.pop("maxlength", None)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
47
src/registrar/templates/domain_org_name_address.html
Normal file
47
src/registrar/templates/domain_org_name_address.html
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
{% extends "domain_base.html" %}
|
||||||
|
{% load static field_helpers%}
|
||||||
|
|
||||||
|
{% block title %}Organization name and mailing address | {{ domain.name }} | {% endblock %}
|
||||||
|
|
||||||
|
{% block domain_content %}
|
||||||
|
{# this is right after the messages block in the parent template #}
|
||||||
|
{% include "includes/form_errors.html" with form=form %}
|
||||||
|
|
||||||
|
<h1>Organization name and mailing address </h1>
|
||||||
|
|
||||||
|
<p>The name of your organization will be publicly listed as the domain registrant.</p>
|
||||||
|
|
||||||
|
{% include "includes/required_fields.html" %}
|
||||||
|
|
||||||
|
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
|
||||||
|
{% csrf_token %}
|
||||||
|
|
||||||
|
{% if domain.domain_info.organization_type == 'federal' %}
|
||||||
|
{% input_with_errors form.federal_agency %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% input_with_errors form.organization_name %}
|
||||||
|
|
||||||
|
{% input_with_errors form.address_line1 %}
|
||||||
|
|
||||||
|
{% input_with_errors form.address_line2 %}
|
||||||
|
|
||||||
|
{% input_with_errors form.city %}
|
||||||
|
|
||||||
|
{% input_with_errors form.state_territory %}
|
||||||
|
|
||||||
|
{% with add_class="usa-input--small" %}
|
||||||
|
{% input_with_errors form.zipcode %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
|
{% input_with_errors form.urbanization %}
|
||||||
|
|
||||||
|
<button
|
||||||
|
type="submit"
|
||||||
|
class="usa-button"
|
||||||
|
>
|
||||||
|
Save
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %} {# domain_content #}
|
|
@ -2,6 +2,7 @@ from .application import *
|
||||||
from .domain import (
|
from .domain import (
|
||||||
DomainView,
|
DomainView,
|
||||||
DomainAuthorizingOfficialView,
|
DomainAuthorizingOfficialView,
|
||||||
|
DomainOrgNameAddressView,
|
||||||
DomainNameserversView,
|
DomainNameserversView,
|
||||||
DomainYourContactInformationView,
|
DomainYourContactInformationView,
|
||||||
DomainSecurityEmailView,
|
DomainSecurityEmailView,
|
||||||
|
|
|
@ -22,10 +22,11 @@ from registrar.models import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from ..forms import (
|
from ..forms import (
|
||||||
DomainAddUserForm,
|
|
||||||
NameserverFormset,
|
|
||||||
DomainSecurityEmailForm,
|
|
||||||
ContactForm,
|
ContactForm,
|
||||||
|
DomainOrgNameAddressForm,
|
||||||
|
DomainAddUserForm,
|
||||||
|
DomainSecurityEmailForm,
|
||||||
|
NameserverFormset,
|
||||||
)
|
)
|
||||||
from ..utility.email import send_templated_email, EmailSendingError
|
from ..utility.email import send_templated_email, EmailSendingError
|
||||||
from .utility import DomainPermissionView, DomainInvitationPermissionDeleteView
|
from .utility import DomainPermissionView, DomainInvitationPermissionDeleteView
|
||||||
|
@ -40,6 +41,46 @@ class DomainView(DomainPermissionView):
|
||||||
|
|
||||||
template_name = "domain_detail.html"
|
template_name = "domain_detail.html"
|
||||||
|
|
||||||
|
class DomainOrgNameAddressView(DomainPermissionView, FormMixin):
|
||||||
|
"""Organization name and mailing address view """
|
||||||
|
model = Domain
|
||||||
|
template_name = "domain_org_name_address.html"
|
||||||
|
context_object_name = "domain"
|
||||||
|
form_class = DomainOrgNameAddressForm
|
||||||
|
|
||||||
|
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.get_object().domain_info
|
||||||
|
return form_kwargs
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
"""Redirect to the overview page for the domain."""
|
||||||
|
return reverse("domain-org-name-address", kwargs={"pk": self.object.pk})
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
"""Form submission posts to this view.
|
||||||
|
|
||||||
|
This post method harmonizes using DetailView and FormMixin together.
|
||||||
|
"""
|
||||||
|
self.object = self.get_object()
|
||||||
|
form = self.get_form()
|
||||||
|
if form.is_valid():
|
||||||
|
return self.form_valid(form)
|
||||||
|
else:
|
||||||
|
return self.form_invalid(form)
|
||||||
|
|
||||||
|
def form_valid(self, form):
|
||||||
|
"""The form is valid, save the organization name and mailing address."""
|
||||||
|
form.save()
|
||||||
|
|
||||||
|
messages.success(
|
||||||
|
self.request, "The organization name and mailing address has been updated."
|
||||||
|
)
|
||||||
|
# superclass has the redirect
|
||||||
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DomainAuthorizingOfficialView(DomainPermissionView, FormMixin):
|
class DomainAuthorizingOfficialView(DomainPermissionView, FormMixin):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue