Merge branch 'main' into nmb/field-validation

This commit is contained in:
Neil Martinsen-Burrell 2022-12-14 14:33:03 -06:00
commit b0debba4e6
No known key found for this signature in database
GPG key ID: 6A3C818CC10D0184
14 changed files with 521 additions and 287 deletions

30
src/Pipfile.lock generated
View file

@ -22,12 +22,6 @@
"markers": "python_version >= '3.7'",
"version": "==3.5.2"
},
"beaker": {
"hashes": [
"sha256:2d5f427e3b13259c98c934cab0e428fc1c18a4c4b94acbdae930df7e7f51d1ec"
],
"version": "==1.12.0"
},
"cachetools": {
"hashes": [
"sha256:6a94c6402995a99c3970cc7e4884bb60b4a8639938157eeed436098bf9831757",
@ -171,10 +165,10 @@
},
"dj-database-url": {
"hashes": [
"sha256:5f2f6b3f65786bac5d3b9e749bff1dcac83398d95778576909697f7b16aee6b9",
"sha256:8be4253439d75412aaad4f82af7aecda956893c87fb8d10edc0adb2d34312527"
"sha256:5c2993b91801c0f78a8b19e642b497b90831124cbade0c265900d4c1037b4730",
"sha256:b23b15046cb38180e0c95207bcc90fe5e9dbde8eef16065907dd85cf4ca7036c"
],
"version": "==1.1.0"
"version": "==1.2.0"
},
"dj-email-url": {
"hashes": [
@ -279,7 +273,7 @@
"hashes": [
"sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2'",
"version": "==0.18.2"
},
"gunicorn": {
@ -362,11 +356,11 @@
},
"oic": {
"hashes": [
"sha256:b82316c4b9633781b8fcb091a7d082ffc863f850a87d8725ead454746aeae677",
"sha256:c1a46dd5f803349f1eea7393d70a3f2bdbc97e73b96f3ebb54843e1dc190f5e4"
"sha256:1bb80d7717faed750f1d8d482c06616a45f1fa5b2295d0620049040b4b48b97e",
"sha256:6cd66c5203baa8cd90dd2b73d0cc83785e96c91fab67fa7b587549fcadb3c092"
],
"index": "pypi",
"version": "==1.4.0"
"version": "==1.5.0"
},
"orderedmultidict": {
"hashes": [
@ -518,7 +512,7 @@
"sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86",
"sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==2.8.2"
},
"python-dotenv": {
@ -550,7 +544,7 @@
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==1.16.0"
},
"sqlparse": {
@ -859,7 +853,7 @@
"sha256:1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926",
"sha256:8abb2f1d86890a2dfb989f9a77cfcfd3e47c2a354b01111771326f8aa26e0254"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==1.16.0"
},
"smmap": {
@ -899,7 +893,7 @@
"sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc",
"sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"
],
"markers": "python_full_version < '3.11.0a7'",
"markers": "python_version < '3.11'",
"version": "==2.0.1"
},
"types-cachetools": {
@ -960,7 +954,7 @@
"sha256:73aae30359291c14fa3b956f8b5ca31960e420c28c1bec002547fb04928cf89b",
"sha256:b64ef5141be559cfade448f044fa45c2260351edcb6a8ef6b7e00c7dcef0c323"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2'",
"version": "==1.8.7"
},
"webtest": {

12
src/package-lock.json generated
View file

@ -1485,9 +1485,9 @@
}
},
"node_modules/decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
"integrity": "sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==",
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz",
"integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==",
"dev": true,
"engines": {
"node": ">=0.10"
@ -8084,9 +8084,9 @@
"dev": true
},
"decode-uri-component": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
"integrity": "sha512-hjf+xovcEn31w/EUYdTXQh/8smFL/dzYjohQGEIgjyNavaJfBY2p5F527Bo1VPATxv0VYTUC2bOcXvqFwk78Og==",
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.2.tgz",
"integrity": "sha512-FqUYQ+8o158GyGTrMFJms9qh3CqTKvAqgqsTnkLI8sKu0028orqBhxNMFkFen0zGyg6epACD32pjVk58ngIErQ==",
"dev": true
},
"default-compare": {

View file

@ -81,17 +81,22 @@ class OrganizationContactForm(RegistrarForm):
required=False,
choices=DomainApplication.AGENCY_CHOICES,
)
organization_name = forms.CharField(label="Organization name")
address_line1 = forms.CharField(label="Address line 1")
organization_name = forms.CharField(label="Organization Name")
address_line1 = forms.CharField(label="Street address")
address_line2 = forms.CharField(
required=False,
label="Address line 2",
label="Street address line 2",
)
city = forms.CharField(label="City")
state_territory = forms.ChoiceField(
label="State/territory",
label="State, territory, or military post",
choices=[("", "--Select--")] + DomainApplication.StateTerritoryChoices.choices,
)
zipcode = forms.CharField(label="ZIP code")
urbanization = forms.CharField(
required=False,
label="Urbanization (Puerto Rico only)",
)
class AuthorizingOfficialForm(RegistrarForm):
@ -480,6 +485,10 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
context["form_titles"] = TITLES
if self.steps.current == Step.ORGANIZATION_CONTACT:
context["is_federal"] = self._is_federal()
if self.steps.current == Step.REVIEW:
context["step_cls"] = Step
application = self.get_application_object()
context["application"] = application
return context
def get_application_object(self) -> DomainApplication:
@ -502,9 +511,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
self.storage.extra_data["application_id"] = application.id
return application
def forms_to_database(
self, forms: dict = None, form: RegistrarForm = None
) -> DomainApplication:
def form_to_database(self, form: RegistrarForm) -> DomainApplication:
"""
Unpack the form responses onto the model object properties.
@ -512,16 +519,8 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
"""
application = self.get_application_object()
if forms:
itr = forms
elif form:
itr = {"form": form}
else:
raise TypeError("forms and form cannot both be None")
for form in itr.values():
if form is not None and hasattr(form, "to_database"):
form.to_database(application)
if form is not None and hasattr(form, "to_database"):
form.to_database(application)
return application
@ -532,7 +531,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
Do not manipulate the form data here.
"""
# save progress
self.forms_to_database(form=form)
self.form_to_database(form=form)
return self.get_form_step_data(form)
def get_form(self, step=None, data=None, files=None):
@ -572,7 +571,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
def done(self, form_list, form_dict, **kwargs):
"""Called when the data for every form is submitted and validated."""
application = self.forms_to_database(forms=form_dict)
application = self.get_application_object()
application.submit() # change the status to submitted
application.save()
logger.debug("Application object saved: %s", application.id)

View file

@ -0,0 +1,30 @@
# Generated by Django 4.1.3 on 2022-12-12 21:00
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("registrar", "0004_domainapplication_federal_agency"),
]
operations = [
migrations.AddField(
model_name="domainapplication",
name="city",
field=models.TextField(blank=True, help_text="City", null=True),
),
migrations.AddField(
model_name="domainapplication",
name="urbanization",
field=models.TextField(blank=True, help_text="Urbanization", null=True),
),
migrations.AlterField(
model_name="domainapplication",
name="federal_agency",
field=models.TextField(
blank=True, help_text="Top level federal agency", null=True
),
),
]

View file

@ -42,9 +42,14 @@ class Contact(models.Model):
db_index=True,
)
def get_formatted_name(self):
"""Returns the contact's name in Western order."""
names = [n for n in [self.first_name, self.middle_name, self.last_name] if n]
return " ".join(names) if names else "Unknown"
def __str__(self):
if self.first_name or self.last_name:
return f"{self.title or ''} {self.first_name or ''} {self.last_name or ''}"
return self.get_formatted_name()
elif self.email:
return self.email
elif self.pk:

View file

@ -28,62 +28,69 @@ class DomainApplication(TimeStampedModel):
]
class StateTerritoryChoices(models.TextChoices):
ALABAMA = "AL", "Alabama"
ALASKA = "AK", "Alaska"
ARIZONA = "AZ", "Arizona"
ARKANSAS = "AR", "Arkansas"
CALIFORNIA = "CA", "California"
COLORADO = "CO", "Colorado"
CONNECTICUT = "CT", "Connecticut"
DELAWARE = "DE", "Delaware"
DISTRICT_OF_COLUMBIA = "DC", "District of Columbia"
FLORIDA = "FL", "Florida"
GEORGIA = "GA", "Georgia"
HAWAII = "HI", "Hawaii"
IDAHO = "ID", "Idaho"
ILLINOIS = "IL", "Illinois"
INDIANA = "IN", "Indiana"
IOWA = "IA", "Iowa"
KANSAS = "KS", "Kansas"
KENTUCKY = "KY", "Kentucky"
LOUISIANA = "LA", "Louisiana"
MAINE = "ME", "Maine"
MARYLAND = "MD", "Maryland"
MASSACHUSETTS = "MA", "Massachusetts"
MICHIGAN = "MI", "Michigan"
MINNESOTA = "MN", "Minnesota"
MISSISSIPPI = "MS", "Mississippi"
MISSOURI = "MO", "Missouri"
MONTANA = "MT", "Montana"
NEBRASKA = "NE", "Nebraska"
NEVADA = "NV", "Nevada"
NEW_HAMPSHIRE = "NH", "New Hampshire"
NEW_JERSEY = "NJ", "New Jersey"
NEW_MEXICO = "NM", "New Mexico"
NEW_YORK = "NY", "New York"
NORTH_CAROLINA = "NC", "North Carolina"
NORTH_DAKOTA = "ND", "North Dakota"
OHIO = "OH", "Ohio"
OKLAHOMA = "OK", "Oklahoma"
OREGON = "OR", "Oregon"
PENNSYLVANIA = "PA", "Pennsylvania"
RHODE_ISLAND = "RI", "Rhode Island"
SOUTH_CAROLINA = "SC", "South Carolina"
SOUTH_DAKOTA = "SD", "South Dakota"
TENNESSEE = "TN", "Tennessee"
TEXAS = "TX", "Texas"
UTAH = "UT", "Utah"
VERMONT = "VT", "Vermont"
VIRGINIA = "VA", "Virginia"
WASHINGTON = "WA", "Washington"
WEST_VIRGINIA = "WV", "West Virginia"
WISCONSIN = "WI", "Wisconsin"
WYOMING = "WY", "Wyoming"
AMERICAN_SAMOA = "AS", "American Samoa"
GUAM = "GU", "Guam"
NORTHERN_MARIANA_ISLANDS = "MP", "Northern Mariana Islands"
PUERTO_RICO = "PR", "Puerto Rico"
VIRGIN_ISLANDS = "VI", "Virgin Islands"
ALABAMA = "AL", "Alabama (AL)"
ALASKA = "AK", "Alaska (AK)"
AMERICAN_SAMOA = "AS", "American Samoa (AS)"
ARIZONA = "AZ", "Arizona (AZ)"
ARKANSAS = "AR", "Arkansas (AR)"
CALIFORNIA = "CA", "California (CA)"
COLORADO = "CO", "Colorado (CO)"
CONNECTICUT = "CT", "Connecticut (CT)"
DELAWARE = "DE", "Delaware (DE)"
DISTRICT_OF_COLUMBIA = "DC", "District of Columbia (DC)"
FLORIDA = "FL", "Florida (FL)"
GEORGIA = "GA", "Georgia (GA)"
GUAM = "GU", "Guam (GU)"
HAWAII = "HI", "Hawaii (HI)"
IDAHO = "ID", "Idaho (ID)"
ILLINOIS = "IL", "Illinois (IL)"
INDIANA = "IN", "Indiana (IN)"
IOWA = "IA", "Iowa (IA)"
KANSAS = "KS", "Kansas (KS)"
KENTUCKY = "KY", "Kentucky (KY)"
LOUISIANA = "LA", "Louisiana (LA)"
MAINE = "ME", "Maine (ME)"
MARYLAND = "MD", "Maryland (MD)"
MASSACHUSETTS = "MA", "Massachusetts (MA)"
MICHIGAN = "MI", "Michigan (MI)"
MINNESOTA = "MN", "Minnesota (MN)"
MISSISSIPPI = "MS", "Mississippi (MS)"
MISSOURI = "MO", "Missouri (MO)"
MONTANA = "MT", "Montana (MT)"
NEBRASKA = "NE", "Nebraska (NE)"
NEVADA = "NV", "Nevada (NV)"
NEW_HAMPSHIRE = "NH", "New Hampshire (NH)"
NEW_JERSEY = "NJ", "New Jersey (NJ)"
NEW_MEXICO = "NM", "New Mexico (NM)"
NEW_YORK = "NY", "New York (NY)"
NORTH_CAROLINA = "NC", "North Carolina (NC)"
NORTH_DAKOTA = "ND", "North Dakota (ND)"
NORTHERN_MARIANA_ISLANDS = "MP", "Northern Mariana Islands (MP)"
OHIO = "OH", "Ohio (OH)"
OKLAHOMA = "OK", "Oklahoma (OK)"
OREGON = "OR", "Oregon (OR)"
PENNSYLVANIA = "PA", "Pennsylvania (PA)"
PUERTO_RICO = "PR", "Puerto Rico (PR)"
RHODE_ISLAND = "RI", "Rhode Island (RI)"
SOUTH_CAROLINA = "SC", "South Carolina (SC)"
SOUTH_DAKOTA = "SD", "South Dakota (SD)"
TENNESSEE = "TN", "Tennessee (TN)"
TEXAS = "TX", "Texas (TX)"
UNITED_STATES_MINOR_OUTLYING_ISLANDS = (
"UM",
"United States Minor Outlying Islands (UM)",
)
UTAH = "UT", "Utah (UT)"
VERMONT = "VT", "Vermont (VT)"
VIRGIN_ISLANDS = "VI", "Virgin Islands (VI)"
VIRGINIA = "VA", "Virginia (VA)"
WASHINGTON = "WA", "Washington (WA)"
WEST_VIRGINIA = "WV", "West Virginia (WV)"
WISCONSIN = "WI", "Wisconsin (WI)"
WYOMING = "WY", "Wyoming (WY)"
ARMED_FORCES_AA = "AA", "Armed Forces Americas (AA)"
ARMED_FORCES_AE = "AE", "Armed Forces Africa, Canada, Europe, Middle East (AE)"
ARMED_FORCES_AP = "AP", "Armed Forces Pacific (AP)"
class OrganizationChoices(models.TextChoices):
FEDERAL = "federal", "Federal: a federal agency"
@ -280,7 +287,7 @@ class DomainApplication(TimeStampedModel):
federal_agency = models.TextField(
null=True,
blank=False,
blank=True,
help_text="Top level federal agency",
)
@ -315,6 +322,11 @@ class DomainApplication(TimeStampedModel):
blank=True,
help_text="Address line 2",
)
city = models.TextField(
null=True,
blank=True,
help_text="City",
)
state_territory = models.CharField(
max_length=2,
null=True,
@ -328,6 +340,11 @@ class DomainApplication(TimeStampedModel):
help_text="ZIP code",
db_index=True,
)
urbanization = models.TextField(
null=True,
blank=True,
help_text="Urbanization",
)
authorizing_official = models.ForeignKey(
"registrar.Contact",

View file

@ -42,7 +42,7 @@
</fieldset>
{{ block.super }}
</form>
{% endblock %}

View file

@ -8,16 +8,87 @@
{{ wizard.management_form }}
{% csrf_token %}
{% for this_step in wizard.steps.all|slice:":-1" %}
<div class="review__step margin-top-2">
{% for step in wizard.steps.all|slice:":-1" %}
<section class="review__step margin-top-205">
<hr />
<div class="review__step__title display-flex flex-justify">
<span class="review__step__name">{{ form_titles|get_item:this_step }}</span>
<a href="{% url wizard.url_name step=this_step %}">Edit </a>
<div class="review__step__value">
<div class="review__step__name">{{ form_titles|get_item:step }}</div>
<div>
{% if step == step_cls.ORGANIZATION_TYPE %}
{{ application.get_organization_type_display|default:"Incomplete" }}
{% endif %}
{% if step == step_cls.ORGANIZATION_FEDERAL %}
{{ application.get_federal_type_display|default:"Incomplete" }}
{% endif %}
{% if step == step_cls.ORGANIZATION_ELECTION %}
{{ application.is_election_board|yesno:"Yes,No,Incomplete" }}
{% endif %}
{% if step == step_cls.ORGANIZATION_CONTACT %}
{% if application.organization_name %}
{% include "includes/organization_address.html" with organization=application %}
{% else %}
Incomplete
{% endif %}
{% endif %}
{% if step == step_cls.AUTHORIZING_OFFICIAL %}
{% if application.authorizing_official %}
{% include "includes/contact.html" with contact=application.authorizing_official %}
{% else %}
Incomplete
{% endif %}
{% endif %}
{% if step == step_cls.CURRENT_SITES %}
<ul class="add-list-reset">
{% for site in application.current_websites.all %}
<li>{{ site.website }}</li>
{% empty %}
<li>None</li>
{% endfor %}
</ul>
{% endif %}
{% if step == step_cls.DOTGOV_DOMAIN %}
<ul class="add-list-reset">
<li>{{ application.requested_domain.name|default:"Incomplete" }}</li>
{% for site in application.alternative_domains.all %}
<li>{{ site.website }}</li>
{% endfor %}
</ul>
{% endif %}
{% if step == step_cls.PURPOSE %}
{{ application.purpose|default:"Incomplete" }}
{% endif %}
{% if step == step_cls.YOUR_CONTACT %}
{% if application.submitter %}
{% include "includes/contact.html" with contact=application.submitter %}
{% else %}
Incomplete
{% endif %}
{% endif %}
{% if step == step_cls.OTHER_CONTACTS %}
{% for other in application.other_contacts.all %}
{% include "includes/contact.html" with contact=other %}
{% empty %}
None
{% endfor %}
{% endif %}
{% if step == step_cls.SECURITY_EMAIL %}
{{ application.security_email|default:"None" }}
{% endif %}
{% if step == step_cls.ANYTHING_ELSE %}
{{ application.anything_else|default:"No" }}
{% endif %}
{% if step == step_cls.REQUIREMENTS %}
{{ application.is_policy_acknowledged|yesno:"Agree,Do not agree,Do not agree" }}
{% endif %}
</div>
</div>
<a
aria-describedby="review_step_title__{{step}}"
href="{% url wizard.url_name step=step %}"
>Edit<span class="sr-only"> {{ form_titles|get_item:step }}</span></a>
</div>
<div class="review__step__value">
&lt;Answer value&gt;
</div>
</div>
</section>
{% endfor %}
{{ block.super }}

View file

@ -0,0 +1,6 @@
<address>
{{ contact.get_formatted_name }}<br />
{% if contact.title %}{{ contact.title }}<br />{% endif %}
{% if contact.email %}{{ contact.email }}<br />{% endif %}
{% if contact.phone %}{{ contact.phone }}{% endif %}
</address>

View file

@ -0,0 +1,25 @@
<address>
{% if organization.organization_name %}
{{ organization.organization_name }}
{% endif %}
{% if organization.address_line1 %}
<br />{{ organization.address_line1 }}
{% endif %}
{% if organization.address_line2 %}
<br />{{ organization.address_line2 }}
{% endif %}
{% if organization.city %}
<br />{{ organization.city }}{% if organization.state_territory %},&nbsp;
{% else %}<br />
{% endif %}
{% endif %}
{% if organization.state_territory %}
{{ organization.state_territory }}
{% endif %}
{% if organization.zipcode %}
<br />{{ organization.zipcode }}
{% endif %}
{% if organization.urbanization %}
<br />{{ organization.urbanization }}
{% endif %}
</address>

View file

@ -183,8 +183,11 @@ class DomainApplicationTests(TestWithUser, WebTest):
org_contact_form = org_contact_page.form
org_contact_form["organization_contact-organization_name"] = "Testorg"
org_contact_form["organization_contact-address_line1"] = "address 1"
org_contact_form["organization_contact-address_line2"] = "address 2"
org_contact_form["organization_contact-city"] = "NYC"
org_contact_form["organization_contact-state_territory"] = "NY"
org_contact_form["organization_contact-zipcode"] = "10002"
org_contact_form["organization_contact-urbanization"] = "URB Royal Oaks"
# test saving the page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
@ -195,8 +198,11 @@ class DomainApplicationTests(TestWithUser, WebTest):
application = DomainApplication.objects.get() # there's only one
self.assertEquals(application.organization_name, "Testorg")
self.assertEquals(application.address_line1, "address 1")
self.assertEquals(application.address_line2, "address 2")
self.assertEquals(application.city, "NYC")
self.assertEquals(application.state_territory, "NY")
self.assertEquals(application.zipcode, "10002")
self.assertEquals(application.urbanization, "URB Royal Oaks")
# test next button
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
@ -212,8 +218,8 @@ class DomainApplicationTests(TestWithUser, WebTest):
# Follow the redirect to the next form page
ao_page = org_contact_result.follow()
ao_form = ao_page.form
ao_form["authorizing_official-first_name"] = "Testy"
ao_form["authorizing_official-last_name"] = "Tester"
ao_form["authorizing_official-first_name"] = "Testy ATO"
ao_form["authorizing_official-last_name"] = "Tester ATO"
ao_form["authorizing_official-title"] = "Chief Tester"
ao_form["authorizing_official-email"] = "testy@town.com"
ao_form["authorizing_official-phone"] = "(555) 555 5555"
@ -225,8 +231,8 @@ class DomainApplicationTests(TestWithUser, WebTest):
self.assertEquals(result["Location"], "/register/authorizing_official/")
# should see results in db
application = DomainApplication.objects.get() # there's only one
self.assertEquals(application.authorizing_official.first_name, "Testy")
self.assertEquals(application.authorizing_official.last_name, "Tester")
self.assertEquals(application.authorizing_official.first_name, "Testy ATO")
self.assertEquals(application.authorizing_official.last_name, "Tester ATO")
self.assertEquals(application.authorizing_official.title, "Chief Tester")
self.assertEquals(application.authorizing_official.email, "testy@town.com")
self.assertEquals(application.authorizing_official.phone, "(555) 555 5555")
@ -294,7 +300,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
# Follow the redirect to the next form page
purpose_page = dotgov_result.follow()
purpose_form = purpose_page.form
purpose_form["purpose-purpose"] = "Purpose of the site"
purpose_form["purpose-purpose"] = "For all kinds of things."
# test saving the page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
@ -303,7 +309,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
self.assertEquals(result["Location"], "/register/purpose/")
# should see results in db
application = DomainApplication.objects.get() # there's only one
self.assertEquals(application.purpose, "Purpose of the site")
self.assertEquals(application.purpose, "For all kinds of things.")
# test next button
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
@ -413,7 +419,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
anything_else_page = security_email_result.follow()
anything_else_form = anything_else_page.form
anything_else_form["anything_else-anything_else"] = "No"
anything_else_form["anything_else-anything_else"] = "Nothing else."
# test saving the page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
@ -422,7 +428,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
self.assertEquals(result["Location"], "/register/anything_else/")
# should see results in db
application = DomainApplication.objects.get() # there's only one
self.assertEquals(application.anything_else, "No")
self.assertEquals(application.anything_else, "Nothing else.")
# test next button
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
@ -458,9 +464,42 @@ class DomainApplicationTests(TestWithUser, WebTest):
# ---- REVIEW AND FINSIHED PAGES ----
# Follow the redirect to the next form page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
review_page = requirements_result.follow()
review_form = review_page.form
# Review page contains all the previously entered data
self.assertContains(review_page, "Federal")
self.assertContains(review_page, "Executive")
self.assertContains(review_page, "Testorg")
self.assertContains(review_page, "address 1")
self.assertContains(review_page, "address 2")
self.assertContains(review_page, "NYC")
self.assertContains(review_page, "NY")
self.assertContains(review_page, "10002")
self.assertContains(review_page, "URB Royal Oaks")
self.assertContains(review_page, "Testy ATO")
self.assertContains(review_page, "Tester ATO")
self.assertContains(review_page, "Chief Tester")
self.assertContains(review_page, "testy@town.com")
self.assertContains(review_page, "(555) 555 5555")
self.assertContains(review_page, "city.com")
self.assertContains(review_page, "city.gov")
self.assertContains(review_page, "city1.gov")
self.assertContains(review_page, "For all kinds of things.")
self.assertContains(review_page, "Testy you")
self.assertContains(review_page, "Tester you")
self.assertContains(review_page, "Admin Tester")
self.assertContains(review_page, "testy-admin@town.com")
self.assertContains(review_page, "(555) 555 5556")
self.assertContains(review_page, "Testy2")
self.assertContains(review_page, "Tester2")
self.assertContains(review_page, "Another Tester")
self.assertContains(review_page, "testy2@town.com")
self.assertContains(review_page, "(555) 555 5557")
self.assertContains(review_page, "security@city.com")
self.assertContains(review_page, "Nothing else.")
# test saving the page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
result = review_page.form.submit("submit_button", value="save")