Skip to content

Commit

Permalink
Merge pull request #3017 from cisagov/za/2927-blocked-from-starting-r…
Browse files Browse the repository at this point in the history
…equests

#2927: Blocked from starting a new domain request when there are other started domain requests - [MEOWARD]
  • Loading branch information
zandercymatics authored Nov 14, 2024
2 parents d080f53 + cea4ba5 commit 764ad7a
Show file tree
Hide file tree
Showing 18 changed files with 246 additions and 214 deletions.
1 change: 1 addition & 0 deletions src/.pa11yci
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"http://localhost:8080/",
"http://localhost:8080/health/",
"http://localhost:8080/request/",
"http://localhost:8080/request/start",
"http://localhost:8080/request/organization/",
"http://localhost:8080/request/org_federal/",
"http://localhost:8080/request/org_election/",
Expand Down
9 changes: 5 additions & 4 deletions src/registrar/config/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@
from api.views import available, rdap, get_current_federal, get_current_full

DOMAIN_REQUEST_NAMESPACE = views.DomainRequestWizard.URL_NAMESPACE

# dynamically generate the other domain_request_urls
domain_request_urls = [
path("", views.DomainRequestWizard.as_view(), name=""),
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"),
]

# dynamically generate the other domain_request_urls
for step, view in [
# add/remove steps here
(Step.ORGANIZATION_TYPE, views.OrganizationType),
Expand All @@ -65,7 +66,7 @@
(PortfolioDomainRequestStep.REQUESTING_ENTITY, views.RequestingEntity),
(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 = [
Expand Down
5 changes: 3 additions & 2 deletions src/registrar/registrar_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ def _handle_user_setup_not_finished(self, request, profile_page):
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.
Otherwise, we assume they want to go to the home page.
"""

# 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.
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)
if not any(request.path.startswith(page) for page in self._get_excluded_pages(profile_page)):
Expand Down
49 changes: 27 additions & 22 deletions src/registrar/templates/domain_request_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,37 @@
</div>
<div class="tablet:grid-col-9">
<main id="main-content" class="grid-container register-form-step">
{% if steps.prev %}
<a href="{% namespaced_url 'domain-request' steps.prev %}" class="breadcrumb__back">
<input type="hidden" class="display-none" id="wizard-domain-request-id" value="{{domain_request_id}}"/>
{% 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">
<use xlink:href="{%static 'img/sprite.svg'%}#arrow_back"></use>
</svg><span class="margin-left-05">Previous step</span>
</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 %}

{% block form_messages %}
Expand Down
2 changes: 1 addition & 1 deletion src/registrar/templates/domain_request_intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h2>Time to complete the form</h2>
<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>
<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%}


Expand Down
2 changes: 1 addition & 1 deletion src/registrar/templates/domain_request_sidebar.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</svg>
{% 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 %}
class="usa-current"
{% else %}
Expand Down
7 changes: 1 addition & 6 deletions src/registrar/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,8 @@

<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">
<a href="{% url 'domain-request:' %}" class="usa-button"
<a href="{% url 'domain-request:start' %}" class="usa-button"
>
Start a new domain request
</a>
Expand Down
2 changes: 1 addition & 1 deletion src/registrar/templates/includes/header_extended.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
>
</li>
<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
>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% for step in steps %}
<section class="summary-item margin-top-3">
{% 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 %}

{% if step == Step.REQUESTING_ENTITY %}
Expand Down
2 changes: 1 addition & 1 deletion src/registrar/templates/includes/request_review_steps.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{% for step in steps %}
<section class="summary-item margin-top-3">
{% 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 %}

{% if step == Step.ORGANIZATION_TYPE %}
Expand Down
8 changes: 2 additions & 6 deletions src/registrar/templates/portfolio_requests.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,9 @@ <h1 id="domain-requests-header">Domain requests</h1>
<p class="margin-y-0">Domain requests can only be modified by the person who created the request.</p>
</div>
<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">
<a href="{% url 'domain-request:' %}" class="usa-button"
<a href="{% url 'domain-request:start' %}" class="usa-button"
>
Start a new domain request
</a>
Expand Down
14 changes: 7 additions & 7 deletions src/registrar/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def test_home_page(self):
@less_console_noise_decorator
def test_domain_request_form_not_logged_in(self):
"""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.assertIn("/login?next=/request/", response.headers["Location"])
self.assertIn("/login?next=/request/start/", response.headers["Location"])


class TestWithUser(MockEppLib):
Expand Down Expand Up @@ -476,7 +476,7 @@ def test_home_deletes_domain_request_and_shared_orphans(self):

@less_console_noise_decorator
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(
response,
"You’re about to start your .gov domain request.",
Expand All @@ -503,7 +503,7 @@ def test_domain_request_form_with_ineligible_user(self):
title="title",
)
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)
restricted_user.delete()

Expand Down Expand Up @@ -718,7 +718,7 @@ def test_new_user_goes_to_domain_request(self):
self.app.set_user(incomplete_regular_user.username)
with override_flag("", active=True):
# 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()

# Assert that we're on the right page
Expand Down Expand Up @@ -914,7 +914,7 @@ def test_home_page_main_nav(self):
@less_console_noise_decorator
def test_new_request_main_nav(self):
"""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")

@less_console_noise_decorator
Expand All @@ -927,7 +927,7 @@ def test_user_profile_main_nav(self):
def test_user_profile_back_button_when_coming_from_domain_request(self):
"""tests user profile,
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, "Go back to your domain request")
self.assertNotContains(response, "Back to manage your domains")
Expand Down
8 changes: 4 additions & 4 deletions src/registrar/tests/test_views_portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ def tearDown(self):
def test_requesting_entity_page_new_request(self):
"""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
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
Expand All @@ -1672,7 +1672,7 @@ def test_requesting_entity_page_new_request(self):
@less_console_noise_decorator
def test_requesting_entity_page_existing_suborg_submission(self):
"""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
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
Expand Down Expand Up @@ -1705,7 +1705,7 @@ def test_requesting_entity_page_existing_suborg_submission(self):
@less_console_noise_decorator
def test_requesting_entity_page_new_suborg_submission(self):
"""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
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
Expand Down Expand Up @@ -1745,7 +1745,7 @@ def test_requesting_entity_page_new_suborg_submission(self):
@less_console_noise_decorator
def test_requesting_entity_page_organization_submission(self):
"""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
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
Expand Down
Loading

0 comments on commit 764ad7a

Please sign in to comment.