mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 12:08:40 +02:00
Merge pull request #3017 from cisagov/za/2927-blocked-from-starting-requests
#2927: Blocked from starting a new domain request when there are other started domain requests - [MEOWARD]
This commit is contained in:
commit
764ad7acee
18 changed files with 247 additions and 215 deletions
|
@ -7,6 +7,7 @@
|
||||||
"http://localhost:8080/",
|
"http://localhost:8080/",
|
||||||
"http://localhost:8080/health/",
|
"http://localhost:8080/health/",
|
||||||
"http://localhost:8080/request/",
|
"http://localhost:8080/request/",
|
||||||
|
"http://localhost:8080/request/start",
|
||||||
"http://localhost:8080/request/organization/",
|
"http://localhost:8080/request/organization/",
|
||||||
"http://localhost:8080/request/org_federal/",
|
"http://localhost:8080/request/org_federal/",
|
||||||
"http://localhost:8080/request/org_election/",
|
"http://localhost:8080/request/org_election/",
|
||||||
|
|
|
@ -39,12 +39,13 @@ from registrar.views.utility import always_404
|
||||||
from api.views import available, rdap, get_current_federal, get_current_full
|
from api.views import available, rdap, get_current_federal, get_current_full
|
||||||
|
|
||||||
DOMAIN_REQUEST_NAMESPACE = views.DomainRequestWizard.URL_NAMESPACE
|
DOMAIN_REQUEST_NAMESPACE = views.DomainRequestWizard.URL_NAMESPACE
|
||||||
domain_request_urls = [
|
|
||||||
path("", views.DomainRequestWizard.as_view(), name=""),
|
|
||||||
path("finished/", views.Finished.as_view(), name="finished"),
|
|
||||||
]
|
|
||||||
|
|
||||||
# dynamically generate the other domain_request_urls
|
# dynamically generate the other domain_request_urls
|
||||||
|
domain_request_urls = [
|
||||||
|
path("", RedirectView.as_view(pattern_name="domain-request:start"), name="redirect-to-start"),
|
||||||
|
path("start/", views.DomainRequestWizard.as_view(), name="start"),
|
||||||
|
path("finished/", views.Finished.as_view(), name="finished"),
|
||||||
|
]
|
||||||
for step, view in [
|
for step, view in [
|
||||||
# add/remove steps here
|
# add/remove steps here
|
||||||
(Step.ORGANIZATION_TYPE, views.OrganizationType),
|
(Step.ORGANIZATION_TYPE, views.OrganizationType),
|
||||||
|
@ -65,7 +66,7 @@ for step, view in [
|
||||||
(PortfolioDomainRequestStep.REQUESTING_ENTITY, views.RequestingEntity),
|
(PortfolioDomainRequestStep.REQUESTING_ENTITY, views.RequestingEntity),
|
||||||
(PortfolioDomainRequestStep.ADDITIONAL_DETAILS, views.PortfolioAdditionalDetails),
|
(PortfolioDomainRequestStep.ADDITIONAL_DETAILS, views.PortfolioAdditionalDetails),
|
||||||
]:
|
]:
|
||||||
domain_request_urls.append(path(f"{step}/", view.as_view(), name=step))
|
domain_request_urls.append(path(f"<int:id>/{step}/", view.as_view(), name=step))
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
|
|
@ -92,7 +92,7 @@ class CheckUserProfileMiddleware:
|
||||||
|
|
||||||
We set the "redirect" query param equal to where the user wants to go.
|
We set the "redirect" query param equal to where the user wants to go.
|
||||||
|
|
||||||
If the user wants to go to '/request/', then we set that
|
If the user wants to go to '/request/start/' or '/request/', then we set that
|
||||||
information in the query param.
|
information in the query param.
|
||||||
|
|
||||||
Otherwise, we assume they want to go to the home page.
|
Otherwise, we assume they want to go to the home page.
|
||||||
|
@ -100,7 +100,8 @@ class CheckUserProfileMiddleware:
|
||||||
|
|
||||||
# In some cases, we don't want to redirect to home. This handles that.
|
# In some cases, we don't want to redirect to home. This handles that.
|
||||||
# Can easily be generalized if need be, but for now lets keep this easy to read.
|
# Can easily be generalized if need be, but for now lets keep this easy to read.
|
||||||
custom_redirect = "domain-request:" if request.path == "/request/" else None
|
start_paths = ["/request/", "/request/start/"]
|
||||||
|
custom_redirect = "domain-request:start" if request.path in start_paths else None
|
||||||
|
|
||||||
# Don't redirect on excluded pages (such as the setup page itself)
|
# Don't redirect on excluded pages (such as the setup page itself)
|
||||||
if not any(request.path.startswith(page) for page in self._get_excluded_pages(profile_page)):
|
if not any(request.path.startswith(page) for page in self._get_excluded_pages(profile_page)):
|
||||||
|
|
|
@ -10,32 +10,37 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="tablet:grid-col-9">
|
<div class="tablet:grid-col-9">
|
||||||
<main id="main-content" class="grid-container register-form-step">
|
<main id="main-content" class="grid-container register-form-step">
|
||||||
{% if steps.prev %}
|
<input type="hidden" class="display-none" id="wizard-domain-request-id" value="{{domain_request_id}}"/>
|
||||||
<a href="{% namespaced_url 'domain-request' steps.prev %}" class="breadcrumb__back">
|
{% if steps.current == steps.first %}
|
||||||
|
{% if portfolio %}
|
||||||
|
{% url 'domain-requests' as url_2 %}
|
||||||
|
{% else %}
|
||||||
|
{% url 'home' as url_2 %}
|
||||||
|
{% endif %}
|
||||||
|
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain request breadcrumb">
|
||||||
|
<ol class="usa-breadcrumb__list">
|
||||||
|
<li class="usa-breadcrumb__list-item">
|
||||||
|
<a href="{{ url_2 }}" class="usa-breadcrumb__link">
|
||||||
|
<span>
|
||||||
|
{% if portfolio%}Domain requests{%else%}Manage your domains{% endif%}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
|
||||||
|
{% if requested_domain__name %}
|
||||||
|
<span>{{ requested_domain__name }}</span>
|
||||||
|
{% else %}
|
||||||
|
<span>New domain request</span>
|
||||||
|
{% endif %}
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
{% elif steps.prev %}
|
||||||
|
<a href="{% namespaced_url 'domain-request' steps.prev id=domain_request_id %}" class="breadcrumb__back">
|
||||||
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
<svg class="usa-icon" aria-hidden="true" focusable="false" role="img" width="24" height="24">
|
||||||
<use xlink:href="{%static 'img/sprite.svg'%}#arrow_back"></use>
|
<use xlink:href="{%static 'img/sprite.svg'%}#arrow_back"></use>
|
||||||
</svg><span class="margin-left-05">Previous step</span>
|
</svg><span class="margin-left-05">Previous step</span>
|
||||||
</a>
|
</a>
|
||||||
{% comment %}
|
|
||||||
TODO: uncomment in #2596
|
|
||||||
{% else %}
|
|
||||||
{% if portfolio %}
|
|
||||||
{% url 'domain-requests' as url_2 %}
|
|
||||||
<nav class="usa-breadcrumb padding-top-0" aria-label="Domain request breadcrumb">
|
|
||||||
<ol class="usa-breadcrumb__list">
|
|
||||||
<li class="usa-breadcrumb__list-item">
|
|
||||||
<a href="{{ url_2 }}" class="usa-breadcrumb__link"><span>Domain requests</span></a>
|
|
||||||
</li>
|
|
||||||
<li class="usa-breadcrumb__list-item usa-current" aria-current="page">
|
|
||||||
{% if requested_domain__name %}
|
|
||||||
<span>{{ requested_domain__name }}</span>
|
|
||||||
{% else %}
|
|
||||||
<span>Start a new domain request</span>
|
|
||||||
{% endif %}
|
|
||||||
</li>
|
|
||||||
</ol>
|
|
||||||
</nav>
|
|
||||||
{% endif %} {% endcomment %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% block form_messages %}
|
{% block form_messages %}
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
<p>If you have <a href="{% public_site_url 'domains/before/#information-you%E2%80%99ll-need-to-complete-the-domain-request-form' %}" target="_blank" class="usa-link">all the information you need</a>,
|
<p>If you have <a href="{% public_site_url 'domains/before/#information-you%E2%80%99ll-need-to-complete-the-domain-request-form' %}" target="_blank" class="usa-link">all the information you need</a>,
|
||||||
completing your domain request might take around 15 minutes.</p>
|
completing your domain request might take around 15 minutes.</p>
|
||||||
<h2>How we’ll reach you</h2>
|
<h2>How we’ll reach you</h2>
|
||||||
<p>While reviewing your domain request, we may need to reach out with questions. We’ll also email you when we complete our review. If the contact information below is not correct, visit <a href="{% url 'user-profile' %}?redirect=domain-request:" class="usa-link">your profile</a> to make updates.</p>
|
<p>While reviewing your domain request, we may need to reach out with questions. We’ll also email you when we complete our review. If the contact information below is not correct, visit <a href="{% url 'user-profile' %}?redirect=domain-request:start" class="usa-link">your profile</a> to make updates.</p>
|
||||||
{% include "includes/profile_information.html" with user=user%}
|
{% include "includes/profile_information.html" with user=user%}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
</svg>
|
</svg>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{% namespaced_url 'domain-request' this_step %}"
|
<a href="{% namespaced_url 'domain-request' this_step id=domain_request_id %}"
|
||||||
{% if this_step == steps.current %}
|
{% if this_step == steps.current %}
|
||||||
class="usa-current"
|
class="usa-current"
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -17,13 +17,8 @@
|
||||||
|
|
||||||
<h1>Manage your domains</h1>
|
<h1>Manage your domains</h1>
|
||||||
|
|
||||||
{% comment %}
|
|
||||||
IMPORTANT:
|
|
||||||
If this button is added on any other page, make sure to update the
|
|
||||||
relevant view to reset request.session["new_request"] = True
|
|
||||||
{% endcomment %}
|
|
||||||
<p class="margin-top-4">
|
<p class="margin-top-4">
|
||||||
<a href="{% url 'domain-request:' %}" class="usa-button"
|
<a href="{% url 'domain-request:start' %}" class="usa-button"
|
||||||
>
|
>
|
||||||
Start a new domain request
|
Start a new domain request
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
<li class="usa-nav__submenu-item">
|
<li class="usa-nav__submenu-item">
|
||||||
<a href="{% url 'domain-request:' %}"
|
<a href="{% url 'domain-request:start' %}"
|
||||||
><span>Start a new domain request</span></a
|
><span>Start a new domain request</span></a
|
||||||
>
|
>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% for step in steps %}
|
{% for step in steps %}
|
||||||
<section class="summary-item margin-top-3">
|
<section class="summary-item margin-top-3">
|
||||||
{% if is_editable %}
|
{% if is_editable %}
|
||||||
{% namespaced_url 'domain-request' step as domain_request_url %}
|
{% namespaced_url 'domain-request' step id=domain_request_id as domain_request_url %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if step == Step.REQUESTING_ENTITY %}
|
{% if step == Step.REQUESTING_ENTITY %}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{% for step in steps %}
|
{% for step in steps %}
|
||||||
<section class="summary-item margin-top-3">
|
<section class="summary-item margin-top-3">
|
||||||
{% if is_editable %}
|
{% if is_editable %}
|
||||||
{% namespaced_url 'domain-request' step as domain_request_url %}
|
{% namespaced_url 'domain-request' step id=domain_request_id as domain_request_url %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if step == Step.ORGANIZATION_TYPE %}
|
{% if step == Step.ORGANIZATION_TYPE %}
|
||||||
|
|
|
@ -22,13 +22,9 @@
|
||||||
<p class="margin-y-0">Domain requests can only be modified by the person who created the request.</p>
|
<p class="margin-y-0">Domain requests can only be modified by the person who created the request.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="mobile:grid-col-12 tablet:grid-col-6">
|
<div class="mobile:grid-col-12 tablet:grid-col-6">
|
||||||
{% comment %}
|
|
||||||
IMPORTANT:
|
|
||||||
If this button is added on any other page, make sure to update the
|
|
||||||
relevant view to reset request.session["new_request"] = True
|
|
||||||
{% endcomment %}
|
|
||||||
<p class="float-right-tablet tablet:margin-y-0">
|
<p class="float-right-tablet tablet:margin-y-0">
|
||||||
<a href="{% url 'domain-request:' %}" class="usa-button"
|
<a href="{% url 'domain-request:start' %}" class="usa-button"
|
||||||
>
|
>
|
||||||
Start a new domain request
|
Start a new domain request
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -49,9 +49,9 @@ class TestViews(TestCase):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_not_logged_in(self):
|
def test_domain_request_form_not_logged_in(self):
|
||||||
"""Domain request form not accessible without a logged-in user."""
|
"""Domain request form not accessible without a logged-in user."""
|
||||||
response = self.client.get("/request/")
|
response = self.client.get(reverse("domain-request:start"))
|
||||||
self.assertEqual(response.status_code, 302)
|
self.assertEqual(response.status_code, 302)
|
||||||
self.assertIn("/login?next=/request/", response.headers["Location"])
|
self.assertIn("/login?next=/request/start/", response.headers["Location"])
|
||||||
|
|
||||||
|
|
||||||
class TestWithUser(MockEppLib):
|
class TestWithUser(MockEppLib):
|
||||||
|
@ -476,7 +476,7 @@ class HomeTests(TestWithUser):
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_view(self):
|
def test_domain_request_form_view(self):
|
||||||
response = self.client.get("/request/", follow=True)
|
response = self.client.get(reverse("domain-request:start"), follow=True)
|
||||||
self.assertContains(
|
self.assertContains(
|
||||||
response,
|
response,
|
||||||
"You’re about to start your .gov domain request.",
|
"You’re about to start your .gov domain request.",
|
||||||
|
@ -503,7 +503,7 @@ class HomeTests(TestWithUser):
|
||||||
title="title",
|
title="title",
|
||||||
)
|
)
|
||||||
self.client.force_login(restricted_user)
|
self.client.force_login(restricted_user)
|
||||||
response = self.client.get("/request/", follow=True)
|
response = self.client.get(reverse("domain-request:start"), follow=True)
|
||||||
self.assertEqual(response.status_code, 403)
|
self.assertEqual(response.status_code, 403)
|
||||||
restricted_user.delete()
|
restricted_user.delete()
|
||||||
|
|
||||||
|
@ -718,7 +718,7 @@ class FinishUserProfileTests(TestWithUser, WebTest):
|
||||||
self.app.set_user(incomplete_regular_user.username)
|
self.app.set_user(incomplete_regular_user.username)
|
||||||
with override_flag("", active=True):
|
with override_flag("", active=True):
|
||||||
# This will redirect the user to the setup page
|
# This will redirect the user to the setup page
|
||||||
finish_setup_page = self.app.get(reverse("domain-request:")).follow()
|
finish_setup_page = self.app.get(reverse("domain-request:start")).follow()
|
||||||
self._set_session_cookie()
|
self._set_session_cookie()
|
||||||
|
|
||||||
# Assert that we're on the right page
|
# Assert that we're on the right page
|
||||||
|
@ -914,7 +914,7 @@ class UserProfileTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_new_request_main_nav(self):
|
def test_new_request_main_nav(self):
|
||||||
"""test that Your profile is in main nav of new request"""
|
"""test that Your profile is in main nav of new request"""
|
||||||
response = self.client.get("/request/", follow=True)
|
response = self.client.get(reverse("domain-request:start"), follow=True)
|
||||||
self.assertContains(response, "Your profile")
|
self.assertContains(response, "Your profile")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
@ -927,7 +927,7 @@ class UserProfileTests(TestWithUser, WebTest):
|
||||||
def test_user_profile_back_button_when_coming_from_domain_request(self):
|
def test_user_profile_back_button_when_coming_from_domain_request(self):
|
||||||
"""tests user profile,
|
"""tests user profile,
|
||||||
and when they are redirected from the domain request page"""
|
and when they are redirected from the domain request page"""
|
||||||
response = self.client.get("/user-profile?redirect=domain-request:")
|
response = self.client.get("/user-profile?redirect=domain-request:start")
|
||||||
self.assertContains(response, "Your profile")
|
self.assertContains(response, "Your profile")
|
||||||
self.assertContains(response, "Go back to your domain request")
|
self.assertContains(response, "Go back to your domain request")
|
||||||
self.assertNotContains(response, "Back to manage your domains")
|
self.assertNotContains(response, "Back to manage your domains")
|
||||||
|
|
|
@ -1645,7 +1645,7 @@ class TestRequestingEntity(WebTest):
|
||||||
def test_requesting_entity_page_new_request(self):
|
def test_requesting_entity_page_new_request(self):
|
||||||
"""Tests that the requesting entity page loads correctly when a new request is started"""
|
"""Tests that the requesting entity page loads correctly when a new request is started"""
|
||||||
|
|
||||||
response = self.app.get(reverse("domain-request:"))
|
response = self.app.get(reverse("domain-request:start"))
|
||||||
|
|
||||||
# Navigate past the intro page
|
# Navigate past the intro page
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
@ -1672,7 +1672,7 @@ class TestRequestingEntity(WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_requesting_entity_page_existing_suborg_submission(self):
|
def test_requesting_entity_page_existing_suborg_submission(self):
|
||||||
"""Tests that you can submit a form on this page and set a suborg"""
|
"""Tests that you can submit a form on this page and set a suborg"""
|
||||||
response = self.app.get(reverse("domain-request:"))
|
response = self.app.get(reverse("domain-request:start"))
|
||||||
|
|
||||||
# Navigate past the intro page
|
# Navigate past the intro page
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
@ -1705,7 +1705,7 @@ class TestRequestingEntity(WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_requesting_entity_page_new_suborg_submission(self):
|
def test_requesting_entity_page_new_suborg_submission(self):
|
||||||
"""Tests that you can submit a form on this page and set a new suborg"""
|
"""Tests that you can submit a form on this page and set a new suborg"""
|
||||||
response = self.app.get(reverse("domain-request:"))
|
response = self.app.get(reverse("domain-request:start"))
|
||||||
|
|
||||||
# Navigate past the intro page
|
# Navigate past the intro page
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
@ -1745,7 +1745,7 @@ class TestRequestingEntity(WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_requesting_entity_page_organization_submission(self):
|
def test_requesting_entity_page_organization_submission(self):
|
||||||
"""Tests submitting an organization on the requesting org form"""
|
"""Tests submitting an organization on the requesting org form"""
|
||||||
response = self.app.get(reverse("domain-request:"))
|
response = self.app.get(reverse("domain-request:start"))
|
||||||
|
|
||||||
# Navigate past the intro page
|
# Navigate past the intro page
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
|
|
@ -49,12 +49,13 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
super().tearDown()
|
super().tearDown()
|
||||||
DomainRequest.objects.all().delete()
|
DomainRequest.objects.all().delete()
|
||||||
DomainInformation.objects.all().delete()
|
DomainInformation.objects.all().delete()
|
||||||
|
User.objects.all().delete()
|
||||||
self.federal_agency.delete()
|
self.federal_agency.delete()
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_intro_acknowledgement(self):
|
def test_domain_request_form_intro_acknowledgement(self):
|
||||||
"""Tests that user is presented with intro acknowledgement page"""
|
"""Tests that user is presented with intro acknowledgement page"""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
self.assertContains(intro_page, "You’re about to start your .gov domain request")
|
self.assertContains(intro_page, "You’re about to start your .gov domain request")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
@ -105,12 +106,12 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
self.assertEqual(detail_page.status_code, 302)
|
self.assertEqual(detail_page.status_code, 302)
|
||||||
# You can access the 'Location' header to get the redirect URL
|
# You can access the 'Location' header to get the redirect URL
|
||||||
redirect_url = detail_page.url
|
redirect_url = detail_page.url
|
||||||
self.assertEqual(redirect_url, "/request/generic_org_type/")
|
self.assertEqual(redirect_url, f"/request/{domain_request.id}/generic_org_type/")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_empty_submit(self):
|
def test_domain_request_form_empty_submit(self):
|
||||||
"""Tests empty submit on the first page after the acknowledgement page"""
|
"""Tests empty submit on the first page after the acknowledgement page"""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -141,7 +142,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
domain_request.save()
|
domain_request.save()
|
||||||
|
|
||||||
# now, attempt to create another one
|
# now, attempt to create another one
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
intro_form = intro_page.forms[0]
|
intro_form = intro_page.forms[0]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
@ -154,59 +155,6 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
self.assertContains(type_page, "You cannot submit this request yet")
|
self.assertContains(type_page, "You cannot submit this request yet")
|
||||||
|
|
||||||
@less_console_noise_decorator
|
|
||||||
def test_domain_request_into_acknowledgement_creates_new_request(self):
|
|
||||||
"""
|
|
||||||
We had to solve a bug where the wizard was creating 2 requests on first intro acknowledgement ('continue')
|
|
||||||
The wizard was also creating multiiple requests on 'continue' -> back button -> 'continue' etc.
|
|
||||||
|
|
||||||
This tests that the domain requests get created only when they should.
|
|
||||||
"""
|
|
||||||
# Get the intro page
|
|
||||||
self.app.get(reverse("home"))
|
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
|
||||||
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
|
||||||
|
|
||||||
# Select the form
|
|
||||||
intro_form = intro_page.forms[0]
|
|
||||||
|
|
||||||
# Submit the form, this creates 1 Request
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
response = intro_form.submit(name="submit_button", value="intro_acknowledge")
|
|
||||||
|
|
||||||
# Landing on the next page used to create another 1 request
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
response.follow()
|
|
||||||
|
|
||||||
# Check if a new DomainRequest object has been created
|
|
||||||
domain_request_count = DomainRequest.objects.count()
|
|
||||||
self.assertEqual(domain_request_count, 1)
|
|
||||||
|
|
||||||
# Let's go back to intro and submit again, this should not create a new request
|
|
||||||
# This is the equivalent of a back button nav from step 1 to intro -> continue
|
|
||||||
intro_form = intro_page.forms[0]
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
type_form = intro_form.submit(name="submit_button", value="intro_acknowledge")
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
type_form.follow()
|
|
||||||
domain_request_count = DomainRequest.objects.count()
|
|
||||||
self.assertEqual(domain_request_count, 1)
|
|
||||||
|
|
||||||
# Go home, which will reset the session flag for new request
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
self.app.get(reverse("home"))
|
|
||||||
|
|
||||||
# This time, clicking continue will create a new request
|
|
||||||
intro_form = intro_page.forms[0]
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
intro_result = intro_form.submit(name="submit_button", value="intro_acknowledge")
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
|
||||||
intro_result.follow()
|
|
||||||
domain_request_count = DomainRequest.objects.count()
|
|
||||||
self.assertEqual(domain_request_count, 2)
|
|
||||||
|
|
||||||
@boto3_mocking.patching
|
@boto3_mocking.patching
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_submission(self):
|
def test_domain_request_form_submission(self):
|
||||||
|
@ -225,7 +173,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
SKIPPED_PAGES = 3
|
SKIPPED_PAGES = 3
|
||||||
num_pages = len(self.TITLES) - SKIPPED_PAGES
|
num_pages = len(self.TITLES) - SKIPPED_PAGES
|
||||||
|
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -253,7 +201,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(type_result.status_code, 302)
|
self.assertEqual(type_result.status_code, 302)
|
||||||
self.assertEqual(type_result["Location"], "/request/organization_federal/")
|
self.assertEqual(type_result["Location"], f"/request/{domain_request.id}/organization_federal/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- FEDERAL BRANCH PAGE ----
|
# ---- FEDERAL BRANCH PAGE ----
|
||||||
|
@ -273,7 +221,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(federal_result.status_code, 302)
|
self.assertEqual(federal_result.status_code, 302)
|
||||||
self.assertEqual(federal_result["Location"], "/request/organization_contact/")
|
self.assertEqual(federal_result["Location"], f"/request/{domain_request.id}/organization_contact/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- ORG CONTACT PAGE ----
|
# ---- ORG CONTACT PAGE ----
|
||||||
|
@ -305,7 +253,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(org_contact_result.status_code, 302)
|
self.assertEqual(org_contact_result.status_code, 302)
|
||||||
self.assertEqual(org_contact_result["Location"], "/request/senior_official/")
|
self.assertEqual(org_contact_result["Location"], f"/request/{domain_request.id}/senior_official/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- SENIOR OFFICIAL PAGE ----
|
# ---- SENIOR OFFICIAL PAGE ----
|
||||||
|
@ -330,7 +278,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(so_result.status_code, 302)
|
self.assertEqual(so_result.status_code, 302)
|
||||||
self.assertEqual(so_result["Location"], "/request/current_sites/")
|
self.assertEqual(so_result["Location"], f"/request/{domain_request.id}/current_sites/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- CURRENT SITES PAGE ----
|
# ---- CURRENT SITES PAGE ----
|
||||||
|
@ -352,7 +300,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(current_sites_result.status_code, 302)
|
self.assertEqual(current_sites_result.status_code, 302)
|
||||||
self.assertEqual(current_sites_result["Location"], "/request/dotgov_domain/")
|
self.assertEqual(current_sites_result["Location"], f"/request/{domain_request.id}/dotgov_domain/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- DOTGOV DOMAIN PAGE ----
|
# ---- DOTGOV DOMAIN PAGE ----
|
||||||
|
@ -372,7 +320,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(dotgov_result.status_code, 302)
|
self.assertEqual(dotgov_result.status_code, 302)
|
||||||
self.assertEqual(dotgov_result["Location"], "/request/purpose/")
|
self.assertEqual(dotgov_result["Location"], f"/request/{domain_request.id}/purpose/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- PURPOSE PAGE ----
|
# ---- PURPOSE PAGE ----
|
||||||
|
@ -391,7 +339,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(purpose_result.status_code, 302)
|
self.assertEqual(purpose_result.status_code, 302)
|
||||||
self.assertEqual(purpose_result["Location"], "/request/other_contacts/")
|
self.assertEqual(purpose_result["Location"], f"/request/{domain_request.id}/other_contacts/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- OTHER CONTACTS PAGE ----
|
# ---- OTHER CONTACTS PAGE ----
|
||||||
|
@ -429,7 +377,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(other_contacts_result.status_code, 302)
|
self.assertEqual(other_contacts_result.status_code, 302)
|
||||||
self.assertEqual(other_contacts_result["Location"], "/request/additional_details/")
|
self.assertEqual(other_contacts_result["Location"], f"/request/{domain_request.id}/additional_details/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- ADDITIONAL DETAILS PAGE ----
|
# ---- ADDITIONAL DETAILS PAGE ----
|
||||||
|
@ -459,7 +407,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(additional_details_result.status_code, 302)
|
self.assertEqual(additional_details_result.status_code, 302)
|
||||||
self.assertEqual(additional_details_result["Location"], "/request/requirements/")
|
self.assertEqual(additional_details_result["Location"], f"/request/{domain_request.id}/requirements/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- REQUIREMENTS PAGE ----
|
# ---- REQUIREMENTS PAGE ----
|
||||||
|
@ -479,7 +427,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(requirements_result.status_code, 302)
|
self.assertEqual(requirements_result.status_code, 302)
|
||||||
self.assertEqual(requirements_result["Location"], "/request/review/")
|
self.assertEqual(requirements_result["Location"], f"/request/{domain_request.id}/review/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- REVIEW AND FINSIHED PAGES ----
|
# ---- REVIEW AND FINSIHED PAGES ----
|
||||||
|
@ -549,7 +497,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
num_pages_tested = 0
|
num_pages_tested = 0
|
||||||
# skipping elections, type_of_work, tribal_government
|
# skipping elections, type_of_work, tribal_government
|
||||||
|
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -577,7 +525,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(type_result.status_code, 302)
|
self.assertEqual(type_result.status_code, 302)
|
||||||
self.assertEqual(type_result["Location"], "/request/organization_federal/")
|
self.assertEqual(type_result["Location"], f"/request/{domain_request.id}/organization_federal/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- FEDERAL BRANCH PAGE ----
|
# ---- FEDERAL BRANCH PAGE ----
|
||||||
|
@ -597,7 +545,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(federal_result.status_code, 302)
|
self.assertEqual(federal_result.status_code, 302)
|
||||||
self.assertEqual(federal_result["Location"], "/request/organization_contact/")
|
self.assertEqual(federal_result["Location"], f"/request/{domain_request.id}/organization_contact/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- ORG CONTACT PAGE ----
|
# ---- ORG CONTACT PAGE ----
|
||||||
|
@ -629,7 +577,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(org_contact_result.status_code, 302)
|
self.assertEqual(org_contact_result.status_code, 302)
|
||||||
self.assertEqual(org_contact_result["Location"], "/request/senior_official/")
|
self.assertEqual(org_contact_result["Location"], f"/request/{domain_request.id}/senior_official/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- SENIOR OFFICIAL PAGE ----
|
# ---- SENIOR OFFICIAL PAGE ----
|
||||||
|
@ -654,7 +602,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(so_result.status_code, 302)
|
self.assertEqual(so_result.status_code, 302)
|
||||||
self.assertEqual(so_result["Location"], "/request/current_sites/")
|
self.assertEqual(so_result["Location"], f"/request/{domain_request.id}/current_sites/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- CURRENT SITES PAGE ----
|
# ---- CURRENT SITES PAGE ----
|
||||||
|
@ -676,7 +624,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(current_sites_result.status_code, 302)
|
self.assertEqual(current_sites_result.status_code, 302)
|
||||||
self.assertEqual(current_sites_result["Location"], "/request/dotgov_domain/")
|
self.assertEqual(current_sites_result["Location"], f"/request/{domain_request.id}/dotgov_domain/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- DOTGOV DOMAIN PAGE ----
|
# ---- DOTGOV DOMAIN PAGE ----
|
||||||
|
@ -696,7 +644,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(dotgov_result.status_code, 302)
|
self.assertEqual(dotgov_result.status_code, 302)
|
||||||
self.assertEqual(dotgov_result["Location"], "/request/purpose/")
|
self.assertEqual(dotgov_result["Location"], f"/request/{domain_request.id}/purpose/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- PURPOSE PAGE ----
|
# ---- PURPOSE PAGE ----
|
||||||
|
@ -715,7 +663,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(purpose_result.status_code, 302)
|
self.assertEqual(purpose_result.status_code, 302)
|
||||||
self.assertEqual(purpose_result["Location"], "/request/other_contacts/")
|
self.assertEqual(purpose_result["Location"], f"/request/{domain_request.id}/other_contacts/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- OTHER CONTACTS PAGE ----
|
# ---- OTHER CONTACTS PAGE ----
|
||||||
|
@ -753,7 +701,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(other_contacts_result.status_code, 302)
|
self.assertEqual(other_contacts_result.status_code, 302)
|
||||||
self.assertEqual(other_contacts_result["Location"], "/request/additional_details/")
|
self.assertEqual(other_contacts_result["Location"], f"/request/{domain_request.id}/additional_details/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- ADDITIONAL DETAILS PAGE ----
|
# ---- ADDITIONAL DETAILS PAGE ----
|
||||||
|
@ -783,7 +731,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(additional_details_result.status_code, 302)
|
self.assertEqual(additional_details_result.status_code, 302)
|
||||||
self.assertEqual(additional_details_result["Location"], "/request/requirements/")
|
self.assertEqual(additional_details_result["Location"], f"/request/{domain_request.id}/requirements/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- REQUIREMENTS PAGE ----
|
# ---- REQUIREMENTS PAGE ----
|
||||||
|
@ -811,7 +759,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the next form in
|
# the post request should return a redirect to the next form in
|
||||||
# the domain request page
|
# the domain request page
|
||||||
self.assertEqual(requirements_result.status_code, 302)
|
self.assertEqual(requirements_result.status_code, 302)
|
||||||
self.assertEqual(requirements_result["Location"], "/request/review/")
|
self.assertEqual(requirements_result["Location"], f"/request/{domain_request.id}/review/")
|
||||||
num_pages_tested += 1
|
num_pages_tested += 1
|
||||||
|
|
||||||
# ---- REVIEW AND FINSIHED PAGES ----
|
# ---- REVIEW AND FINSIHED PAGES ----
|
||||||
|
@ -873,7 +821,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_conditional_federal(self):
|
def test_domain_request_form_conditional_federal(self):
|
||||||
"""Federal branch question is shown for federal organizations."""
|
"""Federal branch question is shown for federal organizations."""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -904,7 +852,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the federal branch
|
# the post request should return a redirect to the federal branch
|
||||||
# question
|
# question
|
||||||
self.assertEqual(type_result.status_code, 302)
|
self.assertEqual(type_result.status_code, 302)
|
||||||
self.assertEqual(type_result["Location"], "/request/organization_federal/")
|
self.assertIn("organization_federal", type_result["Location"])
|
||||||
|
|
||||||
# and the step label should appear in the sidebar of the resulting page
|
# and the step label should appear in the sidebar of the resulting page
|
||||||
# but the step label for the elections page should not appear
|
# but the step label for the elections page should not appear
|
||||||
|
@ -921,7 +869,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the contact
|
# the post request should return a redirect to the contact
|
||||||
# question
|
# question
|
||||||
self.assertEqual(federal_result.status_code, 302)
|
self.assertEqual(federal_result.status_code, 302)
|
||||||
self.assertEqual(federal_result["Location"], "/request/organization_contact/")
|
self.assertIn("organization_federal", type_result["Location"])
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
contact_page = federal_result.follow()
|
contact_page = federal_result.follow()
|
||||||
self.assertContains(contact_page, "Federal agency")
|
self.assertContains(contact_page, "Federal agency")
|
||||||
|
@ -929,7 +877,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_conditional_elections(self):
|
def test_domain_request_form_conditional_elections(self):
|
||||||
"""Election question is shown for other organizations."""
|
"""Election question is shown for other organizations."""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -959,7 +907,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
# the post request should return a redirect to the elections question
|
# the post request should return a redirect to the elections question
|
||||||
self.assertEqual(type_result.status_code, 302)
|
self.assertEqual(type_result.status_code, 302)
|
||||||
self.assertEqual(type_result["Location"], "/request/organization_election/")
|
self.assertIn("organization_election", type_result["Location"])
|
||||||
|
|
||||||
# and the step label should appear in the sidebar of the resulting page
|
# and the step label should appear in the sidebar of the resulting page
|
||||||
# but the step label for the elections page should not appear
|
# but the step label for the elections page should not appear
|
||||||
|
@ -976,7 +924,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the contact
|
# the post request should return a redirect to the contact
|
||||||
# question
|
# question
|
||||||
self.assertEqual(election_result.status_code, 302)
|
self.assertEqual(election_result.status_code, 302)
|
||||||
self.assertEqual(election_result["Location"], "/request/organization_contact/")
|
self.assertIn("organization_contact", election_result["Location"])
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
contact_page = election_result.follow()
|
contact_page = election_result.follow()
|
||||||
self.assertNotContains(contact_page, "Federal agency")
|
self.assertNotContains(contact_page, "Federal agency")
|
||||||
|
@ -984,7 +932,8 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_section_skipping(self):
|
def test_domain_request_form_section_skipping(self):
|
||||||
"""Can skip forward and back in sections"""
|
"""Can skip forward and back in sections"""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
DomainRequest.objects.all().delete()
|
||||||
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -1019,17 +968,20 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# Now click back to the organization type
|
# Now click back to the organization type
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
new_page = federal_page.click(str(self.TITLES["generic_org_type"]), index=0)
|
new_page = federal_page.click(str(self.TITLES["generic_org_type"]), index=0)
|
||||||
|
|
||||||
# Should be a link to the organization_federal page since it is now unlocked
|
# Should be a link to the organization_federal page since it is now unlocked
|
||||||
|
all_domain_requests = DomainRequest.objects.all()
|
||||||
|
self.assertEqual(all_domain_requests.count(), 1)
|
||||||
|
|
||||||
|
new_request_id = all_domain_requests.first().id
|
||||||
self.assertGreater(
|
self.assertGreater(
|
||||||
len(new_page.html.find_all("a", href="/request/organization_federal/")),
|
len(new_page.html.find_all("a", href=f"/request/{new_request_id}/organization_federal/")),
|
||||||
0,
|
0,
|
||||||
)
|
)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_form_nonfederal(self):
|
def test_domain_request_form_nonfederal(self):
|
||||||
"""Non-federal organizations don't have to provide their federal agency."""
|
"""Non-federal organizations don't have to provide their federal agency."""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -1069,12 +1021,12 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
# the post request should return a redirect to the
|
# the post request should return a redirect to the
|
||||||
# about your organization page if it was successful.
|
# about your organization page if it was successful.
|
||||||
self.assertEqual(contact_result.status_code, 302)
|
self.assertEqual(contact_result.status_code, 302)
|
||||||
self.assertEqual(contact_result["Location"], "/request/about_your_organization/")
|
self.assertIn("about_your_organization", contact_result["Location"])
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_about_your_organization_special(self):
|
def test_domain_request_about_your_organization_special(self):
|
||||||
"""Special districts have to answer an additional question."""
|
"""Special districts have to answer an additional question."""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -1104,7 +1056,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
def test_federal_agency_dropdown_excludes_expected_values(self):
|
def test_federal_agency_dropdown_excludes_expected_values(self):
|
||||||
"""The Federal Agency dropdown on a domain request form should not
|
"""The Federal Agency dropdown on a domain request form should not
|
||||||
include options for gov Administration and Non-Federal Agency"""
|
include options for gov Administration and Non-Federal Agency"""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -1152,7 +1104,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
def test_yes_no_contact_form_inits_blank_for_new_domain_request(self):
|
def test_yes_no_contact_form_inits_blank_for_new_domain_request(self):
|
||||||
"""On the Other Contacts page, the yes/no form gets initialized with nothing selected for
|
"""On the Other Contacts page, the yes/no form gets initialized with nothing selected for
|
||||||
new domain requests"""
|
new domain requests"""
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": 0}))
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, None)
|
self.assertEquals(other_contacts_form["other_contacts-has_other_contacts"].value, None)
|
||||||
|
|
||||||
|
@ -1160,7 +1112,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
def test_yes_no_additional_form_inits_blank_for_new_domain_request(self):
|
def test_yes_no_additional_form_inits_blank_for_new_domain_request(self):
|
||||||
"""On the Additional Details page, the yes/no form gets initialized with nothing selected for
|
"""On the Additional Details page, the yes/no form gets initialized with nothing selected for
|
||||||
new domain requests"""
|
new domain requests"""
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(reverse("domain-request:additional_details", kwargs={"id": 0}))
|
||||||
additional_form = additional_details_page.forms[0]
|
additional_form = additional_details_page.forms[0]
|
||||||
|
|
||||||
# Check the cisa representative yes/no field
|
# Check the cisa representative yes/no field
|
||||||
|
@ -1184,7 +1136,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1209,7 +1161,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.pk})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1239,7 +1193,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1268,7 +1222,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.pk})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1306,7 +1262,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.pk})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1368,7 +1326,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.pk})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1413,7 +1373,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.pk})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1444,7 +1406,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.pk})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1481,7 +1445,9 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_page = self.app.get(reverse("domain-request:additional_details"))
|
additional_details_page = self.app.get(
|
||||||
|
reverse("domain-request:additional_details", kwargs={"id": domain_request.id})
|
||||||
|
)
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
additional_details_form = additional_details_page.forms[0]
|
additional_details_form = additional_details_page.forms[0]
|
||||||
|
@ -1512,7 +1478,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1560,7 +1526,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1644,7 +1610,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1685,7 +1651,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_if_yes_no_form_is_no_then_no_other_contacts_required(self):
|
def test_if_yes_no_form_is_no_then_no_other_contacts_required(self):
|
||||||
"""Applicants with no other contacts have to give a reason."""
|
"""Applicants with no other contacts have to give a reason."""
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": 0}))
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
other_contacts_form["other_contacts-has_other_contacts"] = "False"
|
other_contacts_form["other_contacts-has_other_contacts"] = "False"
|
||||||
response = other_contacts_page.forms[0].submit()
|
response = other_contacts_page.forms[0].submit()
|
||||||
|
@ -1701,7 +1667,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_if_yes_no_form_is_yes_then_other_contacts_required(self):
|
def test_if_yes_no_form_is_yes_then_other_contacts_required(self):
|
||||||
"""Applicants with other contacts do not have to give a reason."""
|
"""Applicants with other contacts do not have to give a reason."""
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": 0}))
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
other_contacts_form["other_contacts-has_other_contacts"] = "True"
|
other_contacts_form["other_contacts-has_other_contacts"] = "True"
|
||||||
response = other_contacts_page.forms[0].submit()
|
response = other_contacts_page.forms[0].submit()
|
||||||
|
@ -1777,7 +1743,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.id}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1850,7 +1816,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.id}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -1927,7 +1893,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.id}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -2007,7 +1973,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -2083,7 +2049,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_page = self.app.get(reverse("domain-request:other_contacts"))
|
other_contacts_page = self.app.get(reverse("domain-request:other_contacts", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
other_contacts_form = other_contacts_page.forms[0]
|
other_contacts_form = other_contacts_page.forms[0]
|
||||||
|
@ -2153,7 +2119,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
so_page = self.app.get(reverse("domain-request:senior_official"))
|
so_page = self.app.get(reverse("domain-request:senior_official", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
so_form = so_page.forms[0]
|
so_form = so_page.forms[0]
|
||||||
|
@ -2222,7 +2188,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
so_page = self.app.get(reverse("domain-request:senior_official"))
|
so_page = self.app.get(reverse("domain-request:senior_official", kwargs={"id": domain_request.pk}))
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
so_form = so_page.forms[0]
|
so_form = so_page.forms[0]
|
||||||
|
@ -2303,7 +2269,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_about_your_organiztion_interstate(self):
|
def test_domain_request_about_your_organiztion_interstate(self):
|
||||||
"""Special districts have to answer an additional question."""
|
"""Special districts have to answer an additional question."""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -2332,7 +2298,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_tribal_government(self):
|
def test_domain_request_tribal_government(self):
|
||||||
"""Tribal organizations have to answer an additional question."""
|
"""Tribal organizations have to answer an additional question."""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -2363,7 +2329,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_so_dynamic_text(self):
|
def test_domain_request_so_dynamic_text(self):
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -2447,7 +2413,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_dotgov_domain_dynamic_text(self):
|
def test_domain_request_dotgov_domain_dynamic_text(self):
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -2555,8 +2521,23 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_domain_request_formsets(self):
|
def test_domain_request_formsets(self):
|
||||||
"""Users are able to add more than one of some fields."""
|
"""Users are able to add more than one of some fields."""
|
||||||
current_sites_page = self.app.get(reverse("domain-request:current_sites"))
|
DomainRequest.objects.all().delete()
|
||||||
|
|
||||||
|
# Create a new domain request
|
||||||
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
|
||||||
|
intro_form = intro_page.forms[0]
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
intro_form.submit()
|
||||||
|
|
||||||
|
all_domain_requests = DomainRequest.objects.all()
|
||||||
|
self.assertEqual(all_domain_requests.count(), 1)
|
||||||
|
|
||||||
|
new_domain_request_id = all_domain_requests.first().id
|
||||||
|
|
||||||
|
# Skip to the current sites page
|
||||||
|
current_sites_page = self.app.get(reverse("domain-request:current_sites", kwargs={"id": new_domain_request_id}))
|
||||||
# fill in the form field
|
# fill in the form field
|
||||||
current_sites_form = current_sites_page.forms[0]
|
current_sites_form = current_sites_page.forms[0]
|
||||||
self.assertIn("current_sites-0-website", current_sites_form.fields)
|
self.assertIn("current_sites-0-website", current_sites_form.fields)
|
||||||
|
@ -2573,8 +2554,11 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
value = current_sites_form["current_sites-0-website"].value
|
value = current_sites_form["current_sites-0-website"].value
|
||||||
self.assertEqual(value, "https://example.com")
|
self.assertEqual(value, "https://example.com")
|
||||||
self.assertIn("current_sites-1-website", current_sites_form.fields)
|
self.assertIn("current_sites-1-website", current_sites_form.fields)
|
||||||
|
|
||||||
|
all_domain_requests = DomainRequest.objects.all()
|
||||||
|
self.assertEqual(all_domain_requests.count(), 1, msg="Expected one domain request but got multiple")
|
||||||
# and it is correctly referenced in the ManyToOne relationship
|
# and it is correctly referenced in the ManyToOne relationship
|
||||||
domain_request = DomainRequest.objects.get() # there's only one
|
domain_request = all_domain_requests.first() # there's only one
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
domain_request.current_websites.filter(website="https://example.com").count(),
|
domain_request.current_websites.filter(website="https://example.com").count(),
|
||||||
1,
|
1,
|
||||||
|
@ -2712,7 +2696,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
Make sure the long name is displaying in the domain request form,
|
Make sure the long name is displaying in the domain request form,
|
||||||
org step
|
org step
|
||||||
"""
|
"""
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
# django-webtest does not handle cookie-based sessions well because it keeps
|
# django-webtest does not handle cookie-based sessions well because it keeps
|
||||||
# resetting the session key on each new request, thus destroying the concept
|
# resetting the session key on each new request, thus destroying the concept
|
||||||
# of a "session". We are going to do it manually, saving the session ID here
|
# of a "session". We are going to do it manually, saving the session ID here
|
||||||
|
@ -2738,7 +2722,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
NOTE: This may be a moot point if we implement a more solid pattern in the
|
NOTE: This may be a moot point if we implement a more solid pattern in the
|
||||||
future, like not a submit action at all on the review page."""
|
future, like not a submit action at all on the review page."""
|
||||||
|
|
||||||
review_page = self.app.get(reverse("domain-request:review"))
|
review_page = self.app.get(reverse("domain-request:review", kwargs={"id": 0}))
|
||||||
self.assertContains(review_page, "toggle-submit-domain-request")
|
self.assertContains(review_page, "toggle-submit-domain-request")
|
||||||
self.assertContains(review_page, "Your request form is incomplete")
|
self.assertContains(review_page, "Your request form is incomplete")
|
||||||
|
|
||||||
|
@ -2751,7 +2735,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
user=self.user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_MEMBER]
|
user=self.user, portfolio=portfolio, roles=[UserPortfolioRoleChoices.ORGANIZATION_MEMBER]
|
||||||
)
|
)
|
||||||
# This user should be forbidden from creating new domain requests
|
# This user should be forbidden from creating new domain requests
|
||||||
intro_page = self.app.get(reverse("domain-request:"), expect_errors=True)
|
intro_page = self.app.get(reverse("domain-request:start"), expect_errors=True)
|
||||||
self.assertEqual(intro_page.status_code, 403)
|
self.assertEqual(intro_page.status_code, 403)
|
||||||
|
|
||||||
# This user should also be forbidden from editing existing ones
|
# This user should also be forbidden from editing existing ones
|
||||||
|
@ -2773,7 +2757,7 @@ class DomainRequestTests(TestWithUser, WebTest):
|
||||||
)
|
)
|
||||||
|
|
||||||
# This user should be allowed to create new domain requests
|
# This user should be allowed to create new domain requests
|
||||||
intro_page = self.app.get(reverse("domain-request:"))
|
intro_page = self.app.get(reverse("domain-request:start"))
|
||||||
self.assertEqual(intro_page.status_code, 200)
|
self.assertEqual(intro_page.status_code, 200)
|
||||||
|
|
||||||
# This user should also be allowed to edit existing ones
|
# This user should also be allowed to edit existing ones
|
||||||
|
@ -2975,6 +2959,69 @@ class TestDomainRequestWizard(TestWithUser, WebTest):
|
||||||
DomainRequest.objects.all().delete()
|
DomainRequest.objects.all().delete()
|
||||||
DomainInformation.objects.all().delete()
|
DomainInformation.objects.all().delete()
|
||||||
|
|
||||||
|
@less_console_noise_decorator
|
||||||
|
def test_breadcrumb_navigation(self):
|
||||||
|
"""
|
||||||
|
Tests the breadcrumb navigation behavior in domain request wizard.
|
||||||
|
Ensures that:
|
||||||
|
- Breadcrumb shows correct text based on portfolio flag
|
||||||
|
- Links point to correct destinations
|
||||||
|
- Back button appears on appropriate steps
|
||||||
|
- Back button is not present on first step
|
||||||
|
"""
|
||||||
|
# Create initial domain request
|
||||||
|
domain_request = completed_domain_request(
|
||||||
|
status=DomainRequest.DomainRequestStatus.STARTED,
|
||||||
|
user=self.user,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test without portfolio flag
|
||||||
|
start_page = self.app.get(f"/domain-request/{domain_request.id}/edit/").follow()
|
||||||
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
|
# Check initial breadcrumb state.
|
||||||
|
# Ensure that the request name is shown if it exists, otherwise just show new domain request.
|
||||||
|
self.assertContains(start_page, '<ol class="usa-breadcrumb__list">')
|
||||||
|
self.assertContains(start_page, "city.gov")
|
||||||
|
self.assertContains(start_page, 'href="/"')
|
||||||
|
self.assertContains(start_page, "Manage your domains")
|
||||||
|
self.assertNotContains(start_page, "Previous step")
|
||||||
|
|
||||||
|
# Move to next step
|
||||||
|
form = start_page.forms[0]
|
||||||
|
next_page = form.submit().follow()
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
|
# Verify that the back button appears
|
||||||
|
self.assertContains(next_page, "Previous step")
|
||||||
|
self.assertContains(next_page, "#arrow_back")
|
||||||
|
|
||||||
|
# Test with portfolio flag
|
||||||
|
with override_flag("organization_feature", active=True), override_flag("organization_requests", active=True):
|
||||||
|
portfolio = Portfolio.objects.create(
|
||||||
|
creator=self.user,
|
||||||
|
organization_name="test portfolio",
|
||||||
|
)
|
||||||
|
permission = UserPortfolioPermission.objects.create(
|
||||||
|
user=self.user,
|
||||||
|
portfolio=portfolio,
|
||||||
|
roles=[UserPortfolioRoleChoices.ORGANIZATION_ADMIN],
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check portfolio-specific breadcrumb
|
||||||
|
portfolio_page = self.app.get(f"/domain-request/{domain_request.id}/edit/").follow()
|
||||||
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
|
||||||
|
self.assertContains(portfolio_page, "Domain requests")
|
||||||
|
|
||||||
|
# Clean up portfolio
|
||||||
|
permission.delete()
|
||||||
|
portfolio.delete()
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
domain_request.delete()
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_unlocked_steps_empty_domain_request(self):
|
def test_unlocked_steps_empty_domain_request(self):
|
||||||
"""Test when all fields in the domain request are empty."""
|
"""Test when all fields in the domain request are empty."""
|
||||||
|
@ -3016,7 +3063,7 @@ class TestDomainRequestWizard(TestWithUser, WebTest):
|
||||||
# 10 unlocked steps, one active step, the review step will have link_usa but not check_circle
|
# 10 unlocked steps, one active step, the review step will have link_usa but not check_circle
|
||||||
self.assertContains(detail_page, "#check_circle", count=9)
|
self.assertContains(detail_page, "#check_circle", count=9)
|
||||||
# Type of organization
|
# Type of organization
|
||||||
self.assertContains(detail_page, "usa-current", count=1)
|
self.assertContains(detail_page, "usa-current", count=2)
|
||||||
self.assertContains(detail_page, "link_usa-checked", count=10)
|
self.assertContains(detail_page, "link_usa-checked", count=10)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -3078,7 +3125,7 @@ class TestDomainRequestWizard(TestWithUser, WebTest):
|
||||||
# which unlocks if domain exists), one active step, the review step is locked
|
# which unlocks if domain exists), one active step, the review step is locked
|
||||||
self.assertContains(detail_page, "#check_circle", count=4)
|
self.assertContains(detail_page, "#check_circle", count=4)
|
||||||
# Type of organization
|
# Type of organization
|
||||||
self.assertContains(detail_page, "usa-current", count=1)
|
self.assertContains(detail_page, "usa-current", count=2)
|
||||||
self.assertContains(detail_page, "link_usa-checked", count=4)
|
self.assertContains(detail_page, "link_usa-checked", count=4)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -3152,17 +3199,17 @@ class TestDomainRequestWizard(TestWithUser, WebTest):
|
||||||
self.assertContains(detail_page, "#lock", 1)
|
self.assertContains(detail_page, "#lock", 1)
|
||||||
|
|
||||||
# The current option should be selected
|
# The current option should be selected
|
||||||
self.assertContains(detail_page, "usa-current", count=1)
|
self.assertContains(detail_page, "usa-current", count=2)
|
||||||
|
|
||||||
# We default to the requesting entity page
|
# We default to the requesting entity page
|
||||||
expected_url = reverse("domain-request:portfolio_requesting_entity")
|
expected_url = reverse("domain-request:portfolio_requesting_entity", kwargs={"id": domain_request.id})
|
||||||
# This returns the entire url, thus "in"
|
# This returns the entire url, thus "in"
|
||||||
self.assertIn(expected_url, detail_page.request.url)
|
self.assertIn(expected_url, detail_page.request.url)
|
||||||
|
|
||||||
# We shouldn't show the "domains" and "domain requests" buttons
|
# We shouldn't show the "domains" and "domain requests" buttons
|
||||||
# on this page.
|
# on this page.
|
||||||
self.assertNotContains(detail_page, "Domains")
|
self.assertNotContains(detail_page, "Domains")
|
||||||
self.assertNotContains(detail_page, "Domain requests")
|
self.assertNotContains(detail_page, "<span>Domain requests")
|
||||||
else:
|
else:
|
||||||
self.fail(f"Expected a redirect, but got a different response: {response}")
|
self.fail(f"Expected a redirect, but got a different response: {response}")
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
URL_NAMESPACE = "domain-request"
|
URL_NAMESPACE = "domain-request"
|
||||||
# name for accessing /domain-request/<id>/edit
|
# name for accessing /domain-request/<id>/edit
|
||||||
EDIT_URL_NAME = "edit-domain-request"
|
EDIT_URL_NAME = "edit-domain-request"
|
||||||
NEW_URL_NAME = "/request/"
|
NEW_URL_NAME = "/request/start/"
|
||||||
|
|
||||||
# region: Titles
|
# region: Titles
|
||||||
# We need to pass our human-readable step titles as context to the templates.
|
# We need to pass our human-readable step titles as context to the templates.
|
||||||
|
@ -158,6 +158,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
# Configure titles, wizard_conditions, unlocking_steps, and steps
|
# Configure titles, wizard_conditions, unlocking_steps, and steps
|
||||||
self.configure_step_options()
|
self.configure_step_options()
|
||||||
self._domain_request = None # for caching
|
self._domain_request = None # for caching
|
||||||
|
self.kwargs = {}
|
||||||
|
|
||||||
def configure_step_options(self):
|
def configure_step_options(self):
|
||||||
"""Changes which steps are available to the user based on self.is_portfolio.
|
"""Changes which steps are available to the user based on self.is_portfolio.
|
||||||
|
@ -182,7 +183,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
|
|
||||||
def has_pk(self):
|
def has_pk(self):
|
||||||
"""Does this wizard know about a DomainRequest database record?"""
|
"""Does this wizard know about a DomainRequest database record?"""
|
||||||
return "domain_request_id" in self.storage
|
return bool(self.kwargs.get("id") is not None)
|
||||||
|
|
||||||
def get_step_enum(self):
|
def get_step_enum(self):
|
||||||
"""Determines which step enum we should use for the wizard"""
|
"""Determines which step enum we should use for the wizard"""
|
||||||
|
@ -214,11 +215,10 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
raise ValueError("Invalid value for User")
|
raise ValueError("Invalid value for User")
|
||||||
|
|
||||||
if self.has_pk():
|
if self.has_pk():
|
||||||
id = self.storage["domain_request_id"]
|
|
||||||
try:
|
try:
|
||||||
self._domain_request = DomainRequest.objects.get(
|
self._domain_request = DomainRequest.objects.get(
|
||||||
creator=creator,
|
creator=creator,
|
||||||
pk=id,
|
pk=self.kwargs.get("id"),
|
||||||
)
|
)
|
||||||
return self._domain_request
|
return self._domain_request
|
||||||
except DomainRequest.DoesNotExist:
|
except DomainRequest.DoesNotExist:
|
||||||
|
@ -238,8 +238,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
self._domain_request.save()
|
self._domain_request.save()
|
||||||
else:
|
else:
|
||||||
self._domain_request = DomainRequest.objects.create(creator=self.request.user)
|
self._domain_request = DomainRequest.objects.create(creator=self.request.user)
|
||||||
|
|
||||||
self.storage["domain_request_id"] = self._domain_request.id
|
|
||||||
return self._domain_request
|
return self._domain_request
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -295,6 +293,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
def get(self, request, *args, **kwargs):
|
def get(self, request, *args, **kwargs):
|
||||||
"""This method handles GET requests."""
|
"""This method handles GET requests."""
|
||||||
|
|
||||||
|
self.kwargs = kwargs
|
||||||
if not self.is_portfolio and self.request.user.is_org_user(request):
|
if not self.is_portfolio and self.request.user.is_org_user(request):
|
||||||
self.is_portfolio = True
|
self.is_portfolio = True
|
||||||
# Configure titles, wizard_conditions, unlocking_steps, and steps
|
# Configure titles, wizard_conditions, unlocking_steps, and steps
|
||||||
|
@ -307,7 +306,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
# and remove any prior wizard data from their session
|
# and remove any prior wizard data from their session
|
||||||
if current_url == self.EDIT_URL_NAME and "id" in kwargs:
|
if current_url == self.EDIT_URL_NAME and "id" in kwargs:
|
||||||
del self.storage
|
del self.storage
|
||||||
self.storage["domain_request_id"] = kwargs["id"]
|
|
||||||
|
|
||||||
# if accessing this class directly, redirect to either to an acknowledgement
|
# if accessing this class directly, redirect to either to an acknowledgement
|
||||||
# page or to the first step in the processes (if an edit rather than a new request);
|
# page or to the first step in the processes (if an edit rather than a new request);
|
||||||
|
@ -450,7 +448,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
if self.domain_request.requested_domain is not None:
|
if self.domain_request.requested_domain is not None:
|
||||||
requested_domain_name = self.domain_request.requested_domain.name
|
requested_domain_name = self.domain_request.requested_domain.name
|
||||||
|
|
||||||
context_stuff = {}
|
context = {}
|
||||||
|
|
||||||
# Note: we will want to consolidate the non_org_steps_complete check into the same check that
|
# Note: we will want to consolidate the non_org_steps_complete check into the same check that
|
||||||
# org_steps_complete is using at some point.
|
# org_steps_complete is using at some point.
|
||||||
|
@ -458,7 +456,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
org_steps_complete = len(self.db_check_for_unlocking_steps()) == len(self.steps)
|
org_steps_complete = len(self.db_check_for_unlocking_steps()) == len(self.steps)
|
||||||
if (not self.is_portfolio and non_org_steps_complete) or (self.is_portfolio and org_steps_complete):
|
if (not self.is_portfolio and non_org_steps_complete) or (self.is_portfolio and org_steps_complete):
|
||||||
modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>"
|
modal_button = '<button type="submit" ' 'class="usa-button" ' ">Submit request</button>"
|
||||||
context_stuff = {
|
context = {
|
||||||
"not_form": False,
|
"not_form": False,
|
||||||
"form_titles": self.titles,
|
"form_titles": self.titles,
|
||||||
"steps": self.steps,
|
"steps": self.steps,
|
||||||
|
@ -475,7 +473,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
}
|
}
|
||||||
else: # form is not complete
|
else: # form is not complete
|
||||||
modal_button = '<button type="button" class="usa-button" data-close-modal>Return to request</button>'
|
modal_button = '<button type="button" class="usa-button" data-close-modal>Return to request</button>'
|
||||||
context_stuff = {
|
context = {
|
||||||
"not_form": True,
|
"not_form": True,
|
||||||
"form_titles": self.titles,
|
"form_titles": self.titles,
|
||||||
"steps": self.steps,
|
"steps": self.steps,
|
||||||
|
@ -491,22 +489,19 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
}
|
}
|
||||||
|
|
||||||
# Hides the requests and domains buttons in the navbar
|
# Hides the requests and domains buttons in the navbar
|
||||||
context_stuff["hide_requests"] = self.is_portfolio
|
context["hide_requests"] = self.is_portfolio
|
||||||
context_stuff["hide_domains"] = self.is_portfolio
|
context["hide_domains"] = self.is_portfolio
|
||||||
|
context["domain_request_id"] = self.domain_request.id
|
||||||
|
|
||||||
return context_stuff
|
return context
|
||||||
|
|
||||||
def get_step_list(self) -> list:
|
def get_step_list(self) -> list:
|
||||||
"""Dynamically generated list of steps in the form wizard."""
|
"""Dynamically generated list of steps in the form wizard."""
|
||||||
return request_step_list(self, self.get_step_enum())
|
return request_step_list(self, self.get_step_enum())
|
||||||
|
|
||||||
def goto(self, step):
|
def goto(self, step):
|
||||||
if step == "generic_org_type" or step == "portfolio_requesting_entity":
|
|
||||||
# We need to avoid creating a new domain request if the user
|
|
||||||
# clicks the back button
|
|
||||||
self.request.session["new_request"] = False
|
|
||||||
self.steps.current = step
|
self.steps.current = step
|
||||||
return redirect(reverse(f"{self.URL_NAMESPACE}:{step}"))
|
return redirect(reverse(f"{self.URL_NAMESPACE}:{step}", kwargs={"id": self.domain_request.id}))
|
||||||
|
|
||||||
def goto_next_step(self):
|
def goto_next_step(self):
|
||||||
"""Redirects to the next step."""
|
"""Redirects to the next step."""
|
||||||
|
@ -532,9 +527,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
# which button did the user press?
|
# which button did the user press?
|
||||||
button: str = request.POST.get("submit_button", "")
|
button: str = request.POST.get("submit_button", "")
|
||||||
|
|
||||||
if "new_request" not in request.session:
|
|
||||||
request.session["new_request"] = True
|
|
||||||
|
|
||||||
# if user has acknowledged the intro message
|
# if user has acknowledged the intro message
|
||||||
if button == "intro_acknowledge":
|
if button == "intro_acknowledge":
|
||||||
# Split into a function: C901 'DomainRequestWizard.post' is too complex (11)
|
# Split into a function: C901 'DomainRequestWizard.post' is too complex (11)
|
||||||
|
@ -572,9 +564,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
def handle_intro_acknowledge(self, request):
|
def handle_intro_acknowledge(self, request):
|
||||||
"""If we are starting a new request, clear storage
|
"""If we are starting a new request, clear storage
|
||||||
and redirect to the first step"""
|
and redirect to the first step"""
|
||||||
if request.path_info == self.NEW_URL_NAME:
|
|
||||||
if self.request.session["new_request"] is True:
|
|
||||||
del self.storage
|
|
||||||
return self.goto(self.steps.first)
|
return self.goto(self.steps.first)
|
||||||
|
|
||||||
def save(self, forms: list):
|
def save(self, forms: list):
|
||||||
|
|
|
@ -7,7 +7,6 @@ def index(request):
|
||||||
|
|
||||||
if request and request.user and request.user.is_authenticated:
|
if request and request.user and request.user.is_authenticated:
|
||||||
# This controls the creation of a new domain request in the wizard
|
# This controls the creation of a new domain request in the wizard
|
||||||
request.session["new_request"] = True
|
|
||||||
context["user_domain_count"] = request.user.get_user_domain_ids(request).count()
|
context["user_domain_count"] = request.user.get_user_domain_ids(request).count()
|
||||||
|
|
||||||
return render(request, "home.html", context)
|
return render(request, "home.html", context)
|
||||||
|
|
|
@ -40,8 +40,6 @@ class PortfolioDomainRequestsView(PortfolioDomainRequestsPermissionView, View):
|
||||||
template_name = "portfolio_requests.html"
|
template_name = "portfolio_requests.html"
|
||||||
|
|
||||||
def get(self, request):
|
def get(self, request):
|
||||||
if self.request.user.is_authenticated:
|
|
||||||
request.session["new_request"] = True
|
|
||||||
return render(request, "portfolio_requests.html")
|
return render(request, "portfolio_requests.html")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
||||||
# Set the profile_back_button_text based on the redirect parameter
|
# Set the profile_back_button_text based on the redirect parameter
|
||||||
if kwargs.get("redirect") == "domain-request:":
|
if kwargs.get("redirect") == "domain-request:start":
|
||||||
context["profile_back_button_text"] = "Go back to your domain request"
|
context["profile_back_button_text"] = "Go back to your domain request"
|
||||||
else:
|
else:
|
||||||
context["profile_back_button_text"] = "Go to manage your domains"
|
context["profile_back_button_text"] = "Go to manage your domains"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue