mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-09 22:14:43 +02:00
Include real info in app review page
This commit is contained in:
parent
fc353a1ff6
commit
6fe6e23368
8 changed files with 169 additions and 31 deletions
|
@ -417,6 +417,10 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
|
||||||
context["form_titles"] = TITLES
|
context["form_titles"] = TITLES
|
||||||
if self.steps.current == Step.ORGANIZATION_CONTACT:
|
if self.steps.current == Step.ORGANIZATION_CONTACT:
|
||||||
context["is_federal"] = self._is_federal()
|
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
|
return context
|
||||||
|
|
||||||
def get_application_object(self) -> DomainApplication:
|
def get_application_object(self) -> DomainApplication:
|
||||||
|
@ -439,9 +443,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
|
||||||
self.storage.extra_data["application_id"] = application.id
|
self.storage.extra_data["application_id"] = application.id
|
||||||
return application
|
return application
|
||||||
|
|
||||||
def forms_to_database(
|
def form_to_database(self, form: RegistrarForm) -> DomainApplication:
|
||||||
self, forms: dict = None, form: RegistrarForm = None
|
|
||||||
) -> DomainApplication:
|
|
||||||
"""
|
"""
|
||||||
Unpack the form responses onto the model object properties.
|
Unpack the form responses onto the model object properties.
|
||||||
|
|
||||||
|
@ -449,16 +451,8 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
|
||||||
"""
|
"""
|
||||||
application = self.get_application_object()
|
application = self.get_application_object()
|
||||||
|
|
||||||
if forms:
|
if form is not None and hasattr(form, "to_database"):
|
||||||
itr = forms
|
form.to_database(application)
|
||||||
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)
|
|
||||||
|
|
||||||
return application
|
return application
|
||||||
|
|
||||||
|
@ -469,7 +463,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
|
||||||
Do not manipulate the form data here.
|
Do not manipulate the form data here.
|
||||||
"""
|
"""
|
||||||
# save progress
|
# save progress
|
||||||
self.forms_to_database(form=form)
|
self.form_to_database(form=form)
|
||||||
return self.get_form_step_data(form)
|
return self.get_form_step_data(form)
|
||||||
|
|
||||||
def get_form(self, step=None, data=None, files=None):
|
def get_form(self, step=None, data=None, files=None):
|
||||||
|
@ -509,7 +503,7 @@ class ApplicationWizard(LoginRequiredMixin, NamedUrlSessionWizardView):
|
||||||
|
|
||||||
def done(self, form_list, form_dict, **kwargs):
|
def done(self, form_list, form_dict, **kwargs):
|
||||||
"""Called when the data for every form is submitted and validated."""
|
"""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.submit() # change the status to submitted
|
||||||
application.save()
|
application.save()
|
||||||
logger.debug("Application object saved: %s", application.id)
|
logger.debug("Application object saved: %s", application.id)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
# Generated by Django 4.1.3 on 2022-12-12 14:48
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("registrar", "0005_domainapplication_city_and_more"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="domainapplication",
|
||||||
|
name="federal_agency",
|
||||||
|
field=models.TextField(
|
||||||
|
blank=True, help_text="Top level federal agency", null=True
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -40,9 +40,14 @@ class Contact(models.Model):
|
||||||
db_index=True,
|
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):
|
def __str__(self):
|
||||||
if self.first_name or self.last_name:
|
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:
|
elif self.email:
|
||||||
return self.email
|
return self.email
|
||||||
elif self.pk:
|
elif self.pk:
|
||||||
|
|
|
@ -287,7 +287,7 @@ class DomainApplication(TimeStampedModel):
|
||||||
|
|
||||||
federal_agency = models.TextField(
|
federal_agency = models.TextField(
|
||||||
null=True,
|
null=True,
|
||||||
blank=False,
|
blank=True,
|
||||||
help_text="Top level federal agency",
|
help_text="Top level federal agency",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -8,14 +8,69 @@
|
||||||
{{ wizard.management_form }}
|
{{ wizard.management_form }}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
{% for this_step in wizard.steps.all|slice:":-1" %}
|
{% for step in wizard.steps.all|slice:":-1" %}
|
||||||
<div class="review__step margin-top-2">
|
<div class="review__step margin-top-2">
|
||||||
<div class="review__step__title display-flex flex-justify">
|
<div class="review__step__title display-flex flex-justify">
|
||||||
<span class="review__step__name">{{ form_titles|get_item:this_step }}</span>
|
<div class="review__step__value">
|
||||||
<a href="{% url wizard.url_name step=this_step %}">Edit </a>
|
<div class="review__step__name">{{ form_titles|get_item:step }}</div>
|
||||||
</div>
|
<div>
|
||||||
<div class="review__step__value">
|
{% if step == step_cls.ORGANIZATION_TYPE %}
|
||||||
<Answer value>
|
{{ application.get_organization_type_display }}
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.ORGANIZATION_FEDERAL %}
|
||||||
|
{{ application.get_federal_type_display }}
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.ORGANIZATION_ELECTION %}
|
||||||
|
{{ application.is_election_board|yesno:"Yes,No,Maybe" }}
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.ORGANIZATION_CONTACT %}
|
||||||
|
{% include "includes/organization_address.html" with organization=application %}
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.AUTHORIZING_OFFICIAL %}
|
||||||
|
{% include "includes/contact.html" with contact=application.authorizing_official %}
|
||||||
|
{% 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 }}</li>
|
||||||
|
{% for site in application.alternative_domains.all %}
|
||||||
|
<li>{{ site.website }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.PURPOSE %}
|
||||||
|
{{ application.purpose }}
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.YOUR_CONTACT %}
|
||||||
|
{% include "includes/contact.html" with contact=application.submitter %}
|
||||||
|
{% 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 }}
|
||||||
|
{% endif %}
|
||||||
|
{% if step == step_cls.ANYTHING_ELSE %}
|
||||||
|
{{ application.anything_else }}
|
||||||
|
{% 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>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
6
src/registrar/templates/includes/contact.html
Normal file
6
src/registrar/templates/includes/contact.html
Normal 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>
|
25
src/registrar/templates/includes/organization_address.html
Normal file
25
src/registrar/templates/includes/organization_address.html
Normal 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 %},
|
||||||
|
{% 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>
|
|
@ -218,8 +218,8 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
# Follow the redirect to the next form page
|
# Follow the redirect to the next form page
|
||||||
ao_page = org_contact_result.follow()
|
ao_page = org_contact_result.follow()
|
||||||
ao_form = ao_page.form
|
ao_form = ao_page.form
|
||||||
ao_form["authorizing_official-first_name"] = "Testy"
|
ao_form["authorizing_official-first_name"] = "Testy ATO"
|
||||||
ao_form["authorizing_official-last_name"] = "Tester"
|
ao_form["authorizing_official-last_name"] = "Tester ATO"
|
||||||
ao_form["authorizing_official-title"] = "Chief Tester"
|
ao_form["authorizing_official-title"] = "Chief Tester"
|
||||||
ao_form["authorizing_official-email"] = "testy@town.com"
|
ao_form["authorizing_official-email"] = "testy@town.com"
|
||||||
ao_form["authorizing_official-phone"] = "(555) 555 5555"
|
ao_form["authorizing_official-phone"] = "(555) 555 5555"
|
||||||
|
@ -231,8 +231,8 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
self.assertEquals(result["Location"], "/register/authorizing_official/")
|
self.assertEquals(result["Location"], "/register/authorizing_official/")
|
||||||
# should see results in db
|
# should see results in db
|
||||||
application = DomainApplication.objects.get() # there's only one
|
application = DomainApplication.objects.get() # there's only one
|
||||||
self.assertEquals(application.authorizing_official.first_name, "Testy")
|
self.assertEquals(application.authorizing_official.first_name, "Testy ATO")
|
||||||
self.assertEquals(application.authorizing_official.last_name, "Tester")
|
self.assertEquals(application.authorizing_official.last_name, "Tester ATO")
|
||||||
self.assertEquals(application.authorizing_official.title, "Chief Tester")
|
self.assertEquals(application.authorizing_official.title, "Chief Tester")
|
||||||
self.assertEquals(application.authorizing_official.email, "testy@town.com")
|
self.assertEquals(application.authorizing_official.email, "testy@town.com")
|
||||||
self.assertEquals(application.authorizing_official.phone, "(555) 555 5555")
|
self.assertEquals(application.authorizing_official.phone, "(555) 555 5555")
|
||||||
|
@ -300,7 +300,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
# Follow the redirect to the next form page
|
# Follow the redirect to the next form page
|
||||||
purpose_page = dotgov_result.follow()
|
purpose_page = dotgov_result.follow()
|
||||||
purpose_form = purpose_page.form
|
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
|
# test saving the page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
@ -309,7 +309,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
self.assertEquals(result["Location"], "/register/purpose/")
|
self.assertEquals(result["Location"], "/register/purpose/")
|
||||||
# should see results in db
|
# should see results in db
|
||||||
application = DomainApplication.objects.get() # there's only one
|
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
|
# test next button
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
@ -419,7 +419,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
anything_else_page = security_email_result.follow()
|
anything_else_page = security_email_result.follow()
|
||||||
anything_else_form = anything_else_page.form
|
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
|
# test saving the page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
@ -428,7 +428,7 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
self.assertEquals(result["Location"], "/register/anything_else/")
|
self.assertEquals(result["Location"], "/register/anything_else/")
|
||||||
# should see results in db
|
# should see results in db
|
||||||
application = DomainApplication.objects.get() # there's only one
|
application = DomainApplication.objects.get() # there's only one
|
||||||
self.assertEquals(application.anything_else, "No")
|
self.assertEquals(application.anything_else, "Nothing else.")
|
||||||
|
|
||||||
# test next button
|
# test next button
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
@ -464,9 +464,42 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
# ---- REVIEW AND FINSIHED PAGES ----
|
# ---- REVIEW AND FINSIHED PAGES ----
|
||||||
# Follow the redirect to the next form page
|
# Follow the redirect to the next form page
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
review_page = requirements_result.follow()
|
review_page = requirements_result.follow()
|
||||||
review_form = review_page.form
|
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
|
# test saving the page
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
result = review_page.form.submit("submit_button", value="save")
|
result = review_page.form.submit("submit_button", value="save")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue