From ff7a745ffa7c65ba139740e88d2a0ab3dd4209f9 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Thu, 6 Jun 2024 16:27:24 -0400 Subject: [PATCH 01/16] updated middleware, started on conditional modal --- src/registrar/registrar_middleware.py | 29 +++++++++++-- src/registrar/templates/profile.html | 62 +++++++++++++++++++++++++++ src/registrar/views/user_profile.py | 3 ++ 3 files changed, 90 insertions(+), 4 deletions(-) diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index f9921513b..a1664934a 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -5,6 +5,7 @@ Contains middleware used in settings.py from urllib.parse import parse_qs from django.urls import reverse from django.http import HttpResponseRedirect +from registrar.models.user import User from waffle.decorators import flag_is_active from registrar.models.utility.generic_helper import replace_url_queryparams @@ -38,11 +39,16 @@ class CheckUserProfileMiddleware: self.get_response = get_response self.setup_page = reverse("finish-user-profile-setup") + self.profile_page = reverse("user-profile") self.logout_page = reverse("logout") - self.excluded_pages = [ + self.regular_excluded_pages = [ self.setup_page, self.logout_page, ] + self.other_excluded_pages = [ + self.profile_page, + self.logout_page, + ] def __call__(self, request): response = self.get_response(request) @@ -60,13 +66,17 @@ class CheckUserProfileMiddleware: return None if request.user.is_authenticated: - if hasattr(request.user, "finished_setup") and not request.user.finished_setup: - return self._handle_setup_not_finished(request) + if request.user.verification_type == User.VerificationTypeChoices.REGULAR: + if hasattr(request.user, "finished_setup") and not request.user.finished_setup: + return self._handle_regular_user_setup_not_finished(request) + else: + if hasattr(request.user, "finished_setup") and not request.user.finished_setup: + return self._handle_other_user_setup_not_finished(request) # Continue processing the view return None - def _handle_setup_not_finished(self, request): + def _handle_regular_user_setup_not_finished(self, request): """Redirects the given user to the finish setup page. We set the "redirect" query param equal to where the user wants to go. @@ -98,3 +108,14 @@ class CheckUserProfileMiddleware: else: # Process the view as normal return None + + def _handle_other_user_setup_not_finished(self, request): + """Redirects the given user to the profile page to finish setup. + """ + + # Don't redirect on excluded pages (such as the setup page itself) + if not any(request.path.startswith(page) for page in self.excluded_pages): + return HttpResponseRedirect(self.profile_page) + else: + # Process the view as normal + return None diff --git a/src/registrar/templates/profile.html b/src/registrar/templates/profile.html index c126204bd..61137742e 100644 --- a/src/registrar/templates/profile.html +++ b/src/registrar/templates/profile.html @@ -35,6 +35,68 @@ Edit your User Profile | {% endif %} {% endif %} + + {% if show_confirmation_modal %} +
+
+ +
+ +
+ + +
+
+ {% endif %} {% endblock content %} diff --git a/src/registrar/views/user_profile.py b/src/registrar/views/user_profile.py index 47b01f7cb..060369025 100644 --- a/src/registrar/views/user_profile.py +++ b/src/registrar/views/user_profile.py @@ -41,6 +41,9 @@ class UserProfileView(UserProfilePermissionView, FormMixin): form = self.form_class(instance=self.object) context = self.get_context_data(object=self.object, form=form) + if hasattr(self.object, "finished_setup") and not self.object.finished_setup: + context["show_confirmation_modal"] + return_to_request = request.GET.get("return_to_request") if return_to_request: context["return_to_request"] = True From 1445bba954ac4071a6ca25c27a08971b569a6f36 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 7 Jun 2024 16:47:15 -0400 Subject: [PATCH 02/16] working code --- src/registrar/assets/js/get-gov.js | 12 +++ src/registrar/registrar_middleware.py | 6 +- src/registrar/templates/profile.html | 109 ++++++++++++-------------- src/registrar/views/user_profile.py | 23 ++++-- 4 files changed, 83 insertions(+), 67 deletions(-) diff --git a/src/registrar/assets/js/get-gov.js b/src/registrar/assets/js/get-gov.js index 0d594b315..138c76f3e 100644 --- a/src/registrar/assets/js/get-gov.js +++ b/src/registrar/assets/js/get-gov.js @@ -1301,6 +1301,18 @@ document.addEventListener('DOMContentLoaded', function() { +/** + * An IIFE that displays confirmation modal on the user profile page + */ +(function userProfileListener() { + + const showConfirmationModalTrigger = document.querySelector('.show-confirmation-modal'); + if (showConfirmationModalTrigger) { + showConfirmationModalTrigger.click(); + } +} +)(); + /** * An IIFE that hooks up the edit buttons on the finish-user-setup page */ diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index a1664934a..0b18ef761 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -44,10 +44,12 @@ class CheckUserProfileMiddleware: self.regular_excluded_pages = [ self.setup_page, self.logout_page, + '/admin', ] self.other_excluded_pages = [ self.profile_page, self.logout_page, + '/admin', ] def __call__(self, request): @@ -92,7 +94,7 @@ class CheckUserProfileMiddleware: custom_redirect = "domain-request:" if request.path == "/request/" 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.excluded_pages): + if not any(request.path.startswith(page) for page in self.regular_excluded_pages): # Preserve the original query parameters, and coerce them into a dict query_params = parse_qs(request.META["QUERY_STRING"]) @@ -114,7 +116,7 @@ class CheckUserProfileMiddleware: """ # Don't redirect on excluded pages (such as the setup page itself) - if not any(request.path.startswith(page) for page in self.excluded_pages): + if not any(request.path.startswith(page) for page in self.other_excluded_pages): return HttpResponseRedirect(self.profile_page) else: # Process the view as normal diff --git a/src/registrar/templates/profile.html b/src/registrar/templates/profile.html index 61137742e..16b7e2688 100644 --- a/src/registrar/templates/profile.html +++ b/src/registrar/templates/profile.html @@ -5,6 +5,11 @@ Edit your User Profile | {% endblock title %} {% load static url_helpers %} +{# Disable the redirect #} +{% block logo %} + {% include "includes/gov_extended_logo.html" with logo_clickable=user_finished_setup %} +{% endblock %} + {% block content %}
@@ -37,67 +42,49 @@ Edit your User Profile | {% endif %} {% if show_confirmation_modal %} -
-
- -
- -
- - -
-
+ +
+
+
+ +
+ +
+ +
+
+
{% endif %} + + {% endblock content %} {% block content_bottom %} @@ -105,3 +92,7 @@ Edit your User Profile |
{% endblock content_bottom %} + +{% block footer %} + {% include "includes/footer.html" with show_manage_your_domains=user_finished_setup %} +{% endblock footer %} diff --git a/src/registrar/views/user_profile.py b/src/registrar/views/user_profile.py index 060369025..5fd3c0dd0 100644 --- a/src/registrar/views/user_profile.py +++ b/src/registrar/views/user_profile.py @@ -41,8 +41,8 @@ class UserProfileView(UserProfilePermissionView, FormMixin): form = self.form_class(instance=self.object) context = self.get_context_data(object=self.object, form=form) - if hasattr(self.object, "finished_setup") and not self.object.finished_setup: - context["show_confirmation_modal"] + if hasattr(self.user, "finished_setup") and not self.user.finished_setup: + context["show_confirmation_modal"] = True return_to_request = request.GET.get("return_to_request") if return_to_request: @@ -70,10 +70,15 @@ class UserProfileView(UserProfilePermissionView, FormMixin): # The text for the back button on this page context["profile_back_button_text"] = "Go to manage your domains" - context["show_back_button"] = True + context["show_back_button"] = False + + if hasattr(self.user, "finished_setup") and self.user.finished_setup: + context["user_finished_setup"] = True + context["show_back_button"] = True return context + def get_success_url(self): """Redirect to the user's profile page.""" @@ -96,6 +101,12 @@ class UserProfileView(UserProfilePermissionView, FormMixin): return self.form_valid(form) else: return self.form_invalid(form) + + def form_invalid(self, form): + """If the form is invalid, conditionally display an additional error.""" + if hasattr(self.user, "finished_setup") and not self.user.finished_setup: + messages.error(self.request, "Before you can manage your domain, we need you to add contact information.") + return super().form_invalid(form) def form_valid(self, form): """Handle successful and valid form submissions.""" @@ -108,9 +119,9 @@ class UserProfileView(UserProfilePermissionView, FormMixin): def get_object(self, queryset=None): """Override get_object to return the logged-in user's contact""" - user = self.request.user # get the logged in user - if hasattr(user, "contact"): # Check if the user has a contact instance - return user.contact + self.user = self.request.user # get the logged in user + if hasattr(self.user, "contact"): # Check if the user has a contact instance + return self.user.contact return None From ce89649c7b4009bd7910e8d0466d354d6e6d52e8 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 7 Jun 2024 17:36:09 -0400 Subject: [PATCH 03/16] added unit tests --- src/registrar/tests/test_views.py | 118 ++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 7 deletions(-) diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index f5b055a2b..d9190034d 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -63,11 +63,17 @@ class TestWithUser(MockEppLib): self.user.contact.title = title self.user.contact.save() - username_incomplete = "test_user_incomplete" + username_regular_incomplete = "test_regular_user_incomplete" + username_other_incomplete = "test_other_user_incomplete" first_name_2 = "Incomplete" email_2 = "unicorn@igorville.com" - self.incomplete_user = get_user_model().objects.create( - username=username_incomplete, first_name=first_name_2, email=email_2 + # in the case below, REGULAR user is 'Verified by Login.gov, ie. IAL2 + self.incomplete_regular_user = get_user_model().objects.create( + username=username_regular_incomplete, first_name=first_name_2, email=email_2, verification_type=User.VerificationTypeChoices.REGULAR + ) + # in the case below, other user is representative of GRANDFATHERED, VERIFIED_BY_STAFF, INVITED, FIXTURE_USER, ie. IAL1 + self.incomplete_other_user = get_user_model().objects.create( + username=username_other_incomplete, first_name=first_name_2, email=email_2, verification_type=User.VerificationTypeChoices.VERIFIED_BY_STAFF ) def tearDown(self): @@ -75,8 +81,7 @@ class TestWithUser(MockEppLib): super().tearDown() DomainRequest.objects.all().delete() DomainInformation.objects.all().delete() - self.user.delete() - self.incomplete_user.delete() + User.objects.all().delete() class TestEnvironmentVariablesEffects(TestCase): @@ -525,7 +530,7 @@ class FinishUserProfileTests(TestWithUser, WebTest): @less_console_noise_decorator def test_new_user_with_profile_feature_on(self): """Tests that a new user is redirected to the profile setup page when profile_feature is on""" - self.app.set_user(self.incomplete_user.username) + self.app.set_user(self.incomplete_regular_user.username) with override_flag("profile_feature", active=True): # This will redirect the user to the setup page. # Follow implicity checks if our redirect is working. @@ -564,7 +569,7 @@ class FinishUserProfileTests(TestWithUser, WebTest): def test_new_user_goes_to_domain_request_with_profile_feature_on(self): """Tests that a new user is redirected to the domain request page when profile_feature is on""" - self.app.set_user(self.incomplete_user.username) + self.app.set_user(self.incomplete_regular_user.username) with override_flag("profile_feature", active=True): # This will redirect the user to the setup page finish_setup_page = self.app.get(reverse("domain-request:")).follow() @@ -618,6 +623,105 @@ class FinishUserProfileTests(TestWithUser, WebTest): self.assertContains(response, "You’re about to start your .gov domain request") +class FinishUserProfileForOtherUsersTests(TestWithUser, WebTest): + """A series of tests that target the user profile page intercept for incomplete IAL1 user profiles.""" + + # csrf checks do not work well with WebTest. + # We disable them here. + csrf_checks = False + + def setUp(self): + super().setUp() + self.user.title = None + self.user.save() + self.client.force_login(self.user) + self.domain, _ = Domain.objects.get_or_create(name="sampledomain.gov", state=Domain.State.READY) + self.role, _ = UserDomainRole.objects.get_or_create( + user=self.user, domain=self.domain, role=UserDomainRole.Roles.MANAGER + ) + + def tearDown(self): + super().tearDown() + PublicContact.objects.filter(domain=self.domain).delete() + self.role.delete() + self.domain.delete() + Domain.objects.all().delete() + Website.objects.all().delete() + Contact.objects.all().delete() + + def _set_session_cookie(self): + session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] + self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) + + def _submit_form_webtest(self, form, follow=False): + page = form.submit() + self._set_session_cookie() + return page.follow() if follow else page + + @less_console_noise_decorator + def test_new_user_with_profile_feature_on(self): + """Tests that a new user is redirected to the profile setup page when profile_feature is on, + and testing that the confirmation modal is present""" + self.app.set_user(self.incomplete_other_user.username) + with override_flag("profile_feature", active=True): + # This will redirect the user to the user profile page. + # Follow implicity checks if our redirect is working. + user_profile_page = self.app.get(reverse("home")).follow() + self._set_session_cookie() + + # Assert that we're on the right page by testing for the modal + self.assertContains(user_profile_page, "domain registrants must maintain accurate contact information") + + user_profile_page = self._submit_form_webtest(user_profile_page.form) + + self.assertEqual(user_profile_page.status_code, 200) + + # Assert that modal does not appear on subsequent submits + self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information") + # Assert that unique error message appears by testing the message in a specific div + html_content = user_profile_page.content.decode('utf-8') + # Normalize spaces and line breaks in the HTML content + normalized_html_content = ' '.join(html_content.split()) + # Expected string without extra spaces and line breaks + expected_string = 'Before you can manage your domain, we need you to add contact information.' + # Check for the presence of the
element with the specific text + self.assertIn(f'
{expected_string}
', normalized_html_content) + + + #self.assertContains(user_profile_page, "Before you can manage your domain, we need you to add contact information.") + + # We're missing a phone number, so the page should tell us that + self.assertContains(user_profile_page, "Enter your phone number.") + + # We need to assert that links to manage your domain are not present (in both body and footer) + self.assertNotContains(user_profile_page, "Manage your domains") + # Assert the tooltip on the logo, indicating that the logo is not clickable + self.assertContains(user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."') + # Assert that modal does not appear on subsequent submits + self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information") + + # Add a phone number + finish_setup_form = user_profile_page.form + finish_setup_form["phone"] = "(201) 555-0123" + finish_setup_form["title"] = "CEO" + finish_setup_form["last_name"] = "example" + save_page = self._submit_form_webtest(finish_setup_form, follow=True) + + self.assertEqual(save_page.status_code, 200) + self.assertContains(save_page, "Your profile has been updated.") + + # We need to assert that logo is not clickable and links to manage your domain are not present + self.assertContains(save_page, "anage your domains", count=2) + self.assertNotContains(save_page, "Before you can manage your domains, we need you to add contact information") + # Assert that modal does not appear on subsequent submits + self.assertNotContains(save_page, "domain registrants must maintain accurate contact information") + + # Try to navigate back to the home page. + # This is the same as clicking the back button. + completed_setup_page = self.app.get(reverse("home")) + self.assertContains(completed_setup_page, "Manage your domain") + + class UserProfileTests(TestWithUser, WebTest): """A series of tests that target your profile functionality""" From 7a666c536fa73be5baa9622fe630fb18885cd287 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Fri, 7 Jun 2024 17:41:00 -0400 Subject: [PATCH 04/16] formatted for code readability --- src/registrar/registrar_middleware.py | 9 ++++---- src/registrar/tests/test_views.py | 32 +++++++++++++++++---------- src/registrar/views/user_profile.py | 3 +-- 3 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index 0b18ef761..5e1abeb9b 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -44,12 +44,12 @@ class CheckUserProfileMiddleware: self.regular_excluded_pages = [ self.setup_page, self.logout_page, - '/admin', + "/admin", ] self.other_excluded_pages = [ self.profile_page, self.logout_page, - '/admin', + "/admin", ] def __call__(self, request): @@ -110,10 +110,9 @@ class CheckUserProfileMiddleware: else: # Process the view as normal return None - + def _handle_other_user_setup_not_finished(self, request): - """Redirects the given user to the profile page to finish setup. - """ + """Redirects the given user to the profile page to finish setup.""" # Don't redirect on excluded pages (such as the setup page itself) if not any(request.path.startswith(page) for page in self.other_excluded_pages): diff --git a/src/registrar/tests/test_views.py b/src/registrar/tests/test_views.py index d9190034d..a97aac0e3 100644 --- a/src/registrar/tests/test_views.py +++ b/src/registrar/tests/test_views.py @@ -69,11 +69,18 @@ class TestWithUser(MockEppLib): email_2 = "unicorn@igorville.com" # in the case below, REGULAR user is 'Verified by Login.gov, ie. IAL2 self.incomplete_regular_user = get_user_model().objects.create( - username=username_regular_incomplete, first_name=first_name_2, email=email_2, verification_type=User.VerificationTypeChoices.REGULAR + username=username_regular_incomplete, + first_name=first_name_2, + email=email_2, + verification_type=User.VerificationTypeChoices.REGULAR, ) - # in the case below, other user is representative of GRANDFATHERED, VERIFIED_BY_STAFF, INVITED, FIXTURE_USER, ie. IAL1 + # in the case below, other user is representative of GRANDFATHERED, + # VERIFIED_BY_STAFF, INVITED, FIXTURE_USER, ie. IAL1 self.incomplete_other_user = get_user_model().objects.create( - username=username_other_incomplete, first_name=first_name_2, email=email_2, verification_type=User.VerificationTypeChoices.VERIFIED_BY_STAFF + username=username_other_incomplete, + first_name=first_name_2, + email=email_2, + verification_type=User.VerificationTypeChoices.VERIFIED_BY_STAFF, ) def tearDown(self): @@ -679,24 +686,23 @@ class FinishUserProfileForOtherUsersTests(TestWithUser, WebTest): # Assert that modal does not appear on subsequent submits self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information") # Assert that unique error message appears by testing the message in a specific div - html_content = user_profile_page.content.decode('utf-8') + html_content = user_profile_page.content.decode("utf-8") # Normalize spaces and line breaks in the HTML content - normalized_html_content = ' '.join(html_content.split()) + normalized_html_content = " ".join(html_content.split()) # Expected string without extra spaces and line breaks - expected_string = 'Before you can manage your domain, we need you to add contact information.' + expected_string = "Before you can manage your domain, we need you to add contact information." # Check for the presence of the
element with the specific text self.assertIn(f'
{expected_string}
', normalized_html_content) - - #self.assertContains(user_profile_page, "Before you can manage your domain, we need you to add contact information.") - # We're missing a phone number, so the page should tell us that self.assertContains(user_profile_page, "Enter your phone number.") # We need to assert that links to manage your domain are not present (in both body and footer) self.assertNotContains(user_profile_page, "Manage your domains") # Assert the tooltip on the logo, indicating that the logo is not clickable - self.assertContains(user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."') + self.assertContains( + user_profile_page, 'title="Before you can manage your domains, we need you to add contact information."' + ) # Assert that modal does not appear on subsequent submits self.assertNotContains(user_profile_page, "domain registrants must maintain accurate contact information") @@ -712,10 +718,12 @@ class FinishUserProfileForOtherUsersTests(TestWithUser, WebTest): # We need to assert that logo is not clickable and links to manage your domain are not present self.assertContains(save_page, "anage your domains", count=2) - self.assertNotContains(save_page, "Before you can manage your domains, we need you to add contact information") + self.assertNotContains( + save_page, "Before you can manage your domains, we need you to add contact information" + ) # Assert that modal does not appear on subsequent submits self.assertNotContains(save_page, "domain registrants must maintain accurate contact information") - + # Try to navigate back to the home page. # This is the same as clicking the back button. completed_setup_page = self.app.get(reverse("home")) diff --git a/src/registrar/views/user_profile.py b/src/registrar/views/user_profile.py index 5fd3c0dd0..785ac1528 100644 --- a/src/registrar/views/user_profile.py +++ b/src/registrar/views/user_profile.py @@ -78,7 +78,6 @@ class UserProfileView(UserProfilePermissionView, FormMixin): return context - def get_success_url(self): """Redirect to the user's profile page.""" @@ -101,7 +100,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin): return self.form_valid(form) else: return self.form_invalid(form) - + def form_invalid(self, form): """If the form is invalid, conditionally display an additional error.""" if hasattr(self.user, "finished_setup") and not self.user.finished_setup: From 2586f103424370ceec4291a512e82dd28d7cc54c Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Mon, 10 Jun 2024 22:21:39 -0400 Subject: [PATCH 05/16] refactor wizard, unit test --- src/registrar/tests/test_views_request.py | 22 +++++++++++++ src/registrar/views/domain_request.py | 40 +++++++++++++++-------- 2 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py index 4f2170c87..477199eaa 100644 --- a/src/registrar/tests/test_views_request.py +++ b/src/registrar/tests/test_views_request.py @@ -102,6 +102,28 @@ class DomainRequestTests(TestWithUser, WebTest): self.assertContains(type_page, "You cannot submit this request yet") + 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. + """ + intro_page = self.app.get(reverse("domain-request:")) + 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_result = intro_form.submit() + + # follow first redirect + self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) + intro_result.follow() + session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] + + # should see results in db + domain_request_count = DomainRequest.objects.count() + self.assertEqual(domain_request_count, 1) + @boto3_mocking.patching def test_domain_request_form_submission(self): """ diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 95a139211..ab1061a81 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -1,5 +1,6 @@ import logging from collections import defaultdict +import time from django.http import Http404, HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render from django.urls import resolve, reverse @@ -219,22 +220,22 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): self.storage["domain_request_id"] = kwargs["id"] self.storage["step_history"] = self.db_check_for_unlocking_steps() - # if accessing this class directly, redirect to the first step - # in other words, if `DomainRequestWizard` is called as view - # directly by some redirect or url handler, we'll send users - # either to an acknowledgement page or to the first step in - # the processes (if an edit rather than a new request); subclasses - # will NOT be redirected. The purpose of this is to allow code to - # send users "to the domain request wizard" without needing to - # know which view is first in the list of steps. - context = self.get_context_data() + # 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); + # subclasseswill NOT be redirected. The purpose of this is to allow code to + # send users "to the domain request wizard" without needing to know which view + # is first in the list of steps. if self.__class__ == DomainRequestWizard: if request.path_info == self.NEW_URL_NAME: - context = self.get_context_data() - return render(request, "domain_request_intro.html", context=context) + # del self.storage + # Clear context so the prop getter won't create a request here. + # Creating a request will be handled in the post method for the + # intro page. + return render(request, "domain_request_intro.html", context={}) else: return self.goto(self.steps.first) - + + context = self.get_context_data() self.steps.current = current_url context["forms"] = self.get_forms() @@ -457,11 +458,24 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # which button did the user press? button: str = request.POST.get("submit_button", "") + current_time = time.time() # if user has acknowledged the intro message if button == "intro_acknowledge": + print("intro_acknowledge") if request.path_info == self.NEW_URL_NAME: - del self.storage + print("Creating DomainRequest...") + last_submit_time = request.session.get('last_submit_time', 0) + + # Check if the last submit was very recent, indicating a back button -> submit sequence + if current_time - last_submit_time > 5: # 5 seconds threshold + + # This will trigger the domain_request getter into creating a new DomainRequest + del self.storage + + # Update the last submit time + request.session['last_submit_time'] = current_time + return self.goto(self.steps.first) # if accessing this class directly, redirect to the first step From 7809ab5978e319de898a6a5ca059d09e24f80cd0 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Mon, 10 Jun 2024 22:43:40 -0400 Subject: [PATCH 06/16] solidify unit test --- src/registrar/tests/test_views_request.py | 36 +++++++++++++++++++---- src/registrar/views/domain_request.py | 10 +++---- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py index 477199eaa..d86596cce 100644 --- a/src/registrar/tests/test_views_request.py +++ b/src/registrar/tests/test_views_request.py @@ -109,21 +109,45 @@ class DomainRequestTests(TestWithUser, WebTest): This tests that the domain requests get created only when they should. """ + # Get the intro page intro_page = self.app.get(reverse("domain-request:")) + session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] + + # Select the form intro_form = intro_page.forms[0] - self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) - intro_result = intro_form.submit() - # follow first redirect + # Submit the form, this creates 1 Request self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) - intro_result.follow() - session_id = self.app.cookies[settings.SESSION_COOKIE_NAME] + response = intro_form.submit(name="submit_button", value="intro_acknowledge") - # should see results in db + # 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) + # AGAIN right away, this should NOT cause a new request to be created + # as a small threshold between 'Continue' submits indicate a use of the + # browser back button. + intro_form = intro_page.forms[0] + self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) + response = intro_form.submit(name="submit_button", value="intro_acknowledge") + self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) + response.follow() + domain_request_count = DomainRequest.objects.count() + self.assertEqual(domain_request_count, 1) + + # One more time, dropping session which will set the last_submit_time to 0, + # therefore increasing the threshold and having us expect the creation of a new request + intro_form = intro_page.forms[0] + response = intro_form.submit(name="submit_button", value="intro_acknowledge") + response.follow() + domain_request_count = DomainRequest.objects.count() + self.assertEqual(domain_request_count, 2) + @boto3_mocking.patching def test_domain_request_form_submission(self): """ diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index ab1061a81..71742f627 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -220,7 +220,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): self.storage["domain_request_id"] = kwargs["id"] self.storage["step_history"] = self.db_check_for_unlocking_steps() - # 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); # subclasseswill NOT be redirected. The purpose of this is to allow code to # send users "to the domain request wizard" without needing to know which view @@ -234,7 +234,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): return render(request, "domain_request_intro.html", context={}) else: return self.goto(self.steps.first) - + context = self.get_context_data() self.steps.current = current_url context["forms"] = self.get_forms() @@ -462,10 +462,8 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # if user has acknowledged the intro message if button == "intro_acknowledge": - print("intro_acknowledge") if request.path_info == self.NEW_URL_NAME: - print("Creating DomainRequest...") - last_submit_time = request.session.get('last_submit_time', 0) + last_submit_time = request.session.get("last_submit_time", 0) # Check if the last submit was very recent, indicating a back button -> submit sequence if current_time - last_submit_time > 5: # 5 seconds threshold @@ -474,7 +472,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): del self.storage # Update the last submit time - request.session['last_submit_time'] = current_time + request.session["last_submit_time"] = current_time return self.goto(self.steps.first) From f8f1ec447c5702f71c707b4484ce02587fe7e9af Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Tue, 11 Jun 2024 15:58:11 -0400 Subject: [PATCH 07/16] revise to use session instead of a timer --- src/registrar/tests/test_views_request.py | 28 ++++++++++++--------- src/registrar/views/domain_request.py | 30 +++++++++++++++-------- src/registrar/views/index.py | 4 +++ 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/registrar/tests/test_views_request.py b/src/registrar/tests/test_views_request.py index d86596cce..748293a8b 100644 --- a/src/registrar/tests/test_views_request.py +++ b/src/registrar/tests/test_views_request.py @@ -110,10 +110,12 @@ class DomainRequestTests(TestWithUser, WebTest): This tests that the domain requests get created only when they should. """ # Get the intro page - intro_page = self.app.get(reverse("domain-request:")) - + 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] @@ -129,22 +131,26 @@ class DomainRequestTests(TestWithUser, WebTest): domain_request_count = DomainRequest.objects.count() self.assertEqual(domain_request_count, 1) - # AGAIN right away, this should NOT cause a new request to be created - # as a small threshold between 'Continue' submits indicate a use of the - # browser back button. + # 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) - response = intro_form.submit(name="submit_button", value="intro_acknowledge") + type_form = intro_form.submit(name="submit_button", value="intro_acknowledge") self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id) - response.follow() + type_form.follow() domain_request_count = DomainRequest.objects.count() self.assertEqual(domain_request_count, 1) - # One more time, dropping session which will set the last_submit_time to 0, - # therefore increasing the threshold and having us expect the creation of a new request + # 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] - response = intro_form.submit(name="submit_button", value="intro_acknowledge") - response.follow() + 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) diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 71742f627..6795ede5c 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -1,6 +1,5 @@ import logging from collections import defaultdict -import time from django.http import Http404, HttpResponse, HttpResponseRedirect from django.shortcuts import redirect, render from django.urls import resolve, reverse @@ -108,6 +107,12 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): Step.ABOUT_YOUR_ORGANIZATION: lambda w: w.from_model("show_about_your_organization", False), } + def get_session_data(self, request): + """Retrieve 'global' data from session: + The homepage sets new_request to True for the first Create domain request.""" + is_a_new_request = self.request.session.get("new_request", "No data found") + return is_a_new_request + def __init__(self): super().__init__() self.steps = StepsHelper(self) @@ -436,6 +441,16 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): return step_list def goto(self, step): + if step == "generic_org_type": + # We need to avoid creating a new domain request if the user + # clicks the back button + self.request.session["new_request"] = False + else: + # Reset the above logic to be extra safe; + # we do not want to stumble into a situation where a user + # unkowingly overrites when she thinks she's working on a + # new request + self.request.session["new_request"] = True self.steps.current = step return redirect(reverse(f"{self.URL_NAMESPACE}:{step}")) @@ -458,22 +473,17 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # which button did the user press? button: str = request.POST.get("submit_button", "") - current_time = time.time() - + # If a user hits the new request url directly + if "new_request" not in request.session: + request.session["new_request"] = True # if user has acknowledged the intro message if button == "intro_acknowledge": if request.path_info == self.NEW_URL_NAME: - last_submit_time = request.session.get("last_submit_time", 0) - - # Check if the last submit was very recent, indicating a back button -> submit sequence - if current_time - last_submit_time > 5: # 5 seconds threshold + if self.request.session["new_request"] is True: # This will trigger the domain_request getter into creating a new DomainRequest del self.storage - # Update the last submit time - request.session["last_submit_time"] = current_time - return self.goto(self.steps.first) # if accessing this class directly, redirect to the first step diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py index d2e554255..3eec1c36b 100644 --- a/src/registrar/views/index.py +++ b/src/registrar/views/index.py @@ -30,6 +30,10 @@ def index(request): ) context["modal_button"] = modal_button + # This controls the creation of a new domain request in the wizard + print("will set session") + request.session["new_request"] = True + return render(request, "home.html", context) From e92a4ce0eb26b89d99bf647ee32491bacd3bef2b Mon Sep 17 00:00:00 2001 From: Alysia Broddrick Date: Tue, 11 Jun 2024 13:05:36 -0700 Subject: [PATCH 08/16] added ag sandbox --- .github/workflows/migrate.yaml | 1 + .github/workflows/reset-db.yaml | 1 + ops/manifests/manifest-ag.yaml | 32 ++++++++++++++++++++++++++++++++ src/registrar/config/settings.py | 1 + 4 files changed, 35 insertions(+) create mode 100644 ops/manifests/manifest-ag.yaml diff --git a/.github/workflows/migrate.yaml b/.github/workflows/migrate.yaml index f5815012c..1967a6b92 100644 --- a/.github/workflows/migrate.yaml +++ b/.github/workflows/migrate.yaml @@ -16,6 +16,7 @@ on: - stable - staging - development + - ag - cb - bob - meoward diff --git a/.github/workflows/reset-db.yaml b/.github/workflows/reset-db.yaml index 06638aa05..1277d3064 100644 --- a/.github/workflows/reset-db.yaml +++ b/.github/workflows/reset-db.yaml @@ -16,6 +16,7 @@ on: options: - staging - development + - ag - cb - bob - meoward diff --git a/ops/manifests/manifest-ag.yaml b/ops/manifests/manifest-ag.yaml new file mode 100644 index 000000000..68d630f3e --- /dev/null +++ b/ops/manifests/manifest-ag.yaml @@ -0,0 +1,32 @@ +--- +applications: +- name: getgov-ag + buildpacks: + - python_buildpack + path: ../../src + instances: 1 + memory: 512M + stack: cflinuxfs4 + timeout: 180 + command: ./run.sh + health-check-type: http + health-check-http-endpoint: /health + health-check-invocation-timeout: 40 + env: + # Send stdout and stderr straight to the terminal without buffering + PYTHONUNBUFFERED: yup + # Tell Django where to find its configuration + DJANGO_SETTINGS_MODULE: registrar.config.settings + # Tell Django where it is being hosted + DJANGO_BASE_URL: https://getgov-ag.app.cloud.gov + # Tell Django how much stuff to log + DJANGO_LOG_LEVEL: INFO + # default public site location + GETGOV_PUBLIC_SITE_URL: https://get.gov + # Flag to disable/enable features in prod environments + IS_PRODUCTION: False + routes: + - route: getgov-ag.app.cloud.gov + services: + - getgov-credentials + - getgov-ag-database diff --git a/src/registrar/config/settings.py b/src/registrar/config/settings.py index 851f3550c..c4c379307 100644 --- a/src/registrar/config/settings.py +++ b/src/registrar/config/settings.py @@ -659,6 +659,7 @@ ALLOWED_HOSTS = [ "getgov-stable.app.cloud.gov", "getgov-staging.app.cloud.gov", "getgov-development.app.cloud.gov", + "getgov-ag.app.cloud.gov", "getgov-cb.app.cloud.gov", "getgov-bob.app.cloud.gov", "getgov-meoward.app.cloud.gov", From dfd4e2c372dada8f0415b4a102702904f6ff9f08 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Tue, 11 Jun 2024 16:10:58 -0400 Subject: [PATCH 09/16] missing profile_feature context --- src/registrar/views/domain_request.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 6795ede5c..325ac8a52 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -232,11 +232,14 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # is first in the list of steps. if self.__class__ == DomainRequestWizard: if request.path_info == self.NEW_URL_NAME: - # del self.storage # Clear context so the prop getter won't create a request here. # Creating a request will be handled in the post method for the - # intro page. - return render(request, "domain_request_intro.html", context={}) + # intro page. Only TEMPORARY context needed is has_profile_flag + has_profile_flag = flag_is_active(self.request, "profile_feature") + context_stuff = { + "has_profile_feature_flag": has_profile_flag + } + return render(request, "domain_request_intro.html", context=context_stuff) else: return self.goto(self.steps.first) From 48e2673b1bdc35a5f1c17bd8f8b31ef886db5d1d Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Tue, 11 Jun 2024 16:13:18 -0400 Subject: [PATCH 10/16] cleanup --- src/registrar/views/index.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/registrar/views/index.py b/src/registrar/views/index.py index 3eec1c36b..4d8c8fbc2 100644 --- a/src/registrar/views/index.py +++ b/src/registrar/views/index.py @@ -31,7 +31,6 @@ def index(request): context["modal_button"] = modal_button # This controls the creation of a new domain request in the wizard - print("will set session") request.session["new_request"] = True return render(request, "home.html", context) From 856d1f81fc44588398fc54f46ba17571ccf7d7f5 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Wed, 12 Jun 2024 13:17:48 -0400 Subject: [PATCH 11/16] lint --- src/registrar/views/domain_request.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index 325ac8a52..de567c1be 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -236,9 +236,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # Creating a request will be handled in the post method for the # intro page. Only TEMPORARY context needed is has_profile_flag has_profile_flag = flag_is_active(self.request, "profile_feature") - context_stuff = { - "has_profile_feature_flag": has_profile_flag - } + context_stuff = {"has_profile_feature_flag": has_profile_flag} return render(request, "domain_request_intro.html", context=context_stuff) else: return self.goto(self.steps.first) From 956c320a1b49f271c71113f59af46d516f6c00cc Mon Sep 17 00:00:00 2001 From: Rachid Mrad <107004823+rachidatecs@users.noreply.github.com> Date: Wed, 12 Jun 2024 20:57:40 -0400 Subject: [PATCH 12/16] Update src/registrar/views/domain_request.py Co-authored-by: Alysia Broddrick <109625347+abroddrick@users.noreply.github.com> --- src/registrar/views/domain_request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index de567c1be..eb87aa52c 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -449,7 +449,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): else: # Reset the above logic to be extra safe; # we do not want to stumble into a situation where a user - # unkowingly overrites when she thinks she's working on a + # unknowingly overwrites when she thinks she's working on a # new request self.request.session["new_request"] = True self.steps.current = step From dbd418dc48cd9caa8e8621a75727203b08de8199 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Fri, 14 Jun 2024 13:53:33 -0400 Subject: [PATCH 13/16] cleanup --- src/registrar/forms/user_profile.py | 2 +- src/registrar/registrar_middleware.py | 7 +++---- src/registrar/templates/profile.html | 12 +++++++++++- src/registrar/views/user_profile.py | 7 ++++++- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/registrar/forms/user_profile.py b/src/registrar/forms/user_profile.py index 557e34e0d..3dd8cbdce 100644 --- a/src/registrar/forms/user_profile.py +++ b/src/registrar/forms/user_profile.py @@ -47,7 +47,7 @@ class UserProfileForm(forms.ModelForm): self.fields["middle_name"].label = "Middle name (optional)" self.fields["last_name"].label = "Last name / family name" self.fields["title"].label = "Title or role in your organization" - self.fields["email"].label = "Organizational email" + self.fields["email"].label = "Organization email" # Set custom error messages self.fields["first_name"].error_messages = {"required": "Enter your first name / given name."} diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index 5e1abeb9b..79e3b7a11 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -68,11 +68,10 @@ class CheckUserProfileMiddleware: return None if request.user.is_authenticated: - if request.user.verification_type == User.VerificationTypeChoices.REGULAR: - if hasattr(request.user, "finished_setup") and not request.user.finished_setup: + if hasattr(request.user, "finished_setup") and not request.user.finished_setup: + if request.user.verification_type == User.VerificationTypeChoices.REGULAR: return self._handle_regular_user_setup_not_finished(request) - else: - if hasattr(request.user, "finished_setup") and not request.user.finished_setup: + else: return self._handle_other_user_setup_not_finished(request) # Continue processing the view diff --git a/src/registrar/templates/profile.html b/src/registrar/templates/profile.html index 16b7e2688..dd371b930 100644 --- a/src/registrar/templates/profile.html +++ b/src/registrar/templates/profile.html @@ -49,7 +49,7 @@ Edit your User Profile | data-open-modal >Open confirmation modal
+
{% endif %} diff --git a/src/registrar/views/user_profile.py b/src/registrar/views/user_profile.py index 785ac1528..f148f5652 100644 --- a/src/registrar/views/user_profile.py +++ b/src/registrar/views/user_profile.py @@ -15,6 +15,7 @@ from django.urls import NoReverseMatch, reverse from registrar.models import ( Contact, ) +from registrar.models.user import User from registrar.models.utility.generic_helper import replace_url_queryparams from registrar.views.utility.permission_views import UserProfilePermissionView from waffle.decorators import flag_is_active, waffle_flag @@ -41,7 +42,11 @@ class UserProfileView(UserProfilePermissionView, FormMixin): form = self.form_class(instance=self.object) context = self.get_context_data(object=self.object, form=form) - if hasattr(self.user, "finished_setup") and not self.user.finished_setup: + if ( + hasattr(self.user, "finished_setup") + and not self.user.finished_setup + and self.user.verification_type != User.VerificationTypeChoices.REGULAR + ): context["show_confirmation_modal"] = True return_to_request = request.GET.get("return_to_request") From f444a12a455de49ffc7e77e8df7d49438406a303 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 17 Jun 2024 14:11:47 -0400 Subject: [PATCH 14/16] added data-force-action to modal for profile --- src/registrar/templates/profile.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/registrar/templates/profile.html b/src/registrar/templates/profile.html index dd371b930..c62d0a7c1 100644 --- a/src/registrar/templates/profile.html +++ b/src/registrar/templates/profile.html @@ -53,6 +53,7 @@ Edit your User Profile | id="toggle-confirmation-modal" aria-labelledby="Add contact information" aria-describedby="Add contact information" + data-force-action >
From cb810c5639f49b148119b6cdf54469d95aeaa370 Mon Sep 17 00:00:00 2001 From: David Kennedy Date: Mon, 17 Jun 2024 14:38:29 -0400 Subject: [PATCH 15/16] updating divider between header items --- src/registrar/assets/sass/_theme/_base.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/assets/sass/_theme/_base.scss b/src/registrar/assets/sass/_theme/_base.scss index e88d75f4e..e5e8b89ee 100644 --- a/src/registrar/assets/sass/_theme/_base.scss +++ b/src/registrar/assets/sass/_theme/_base.scss @@ -70,7 +70,7 @@ body { top: 50%; left: 0; width: 0; /* No width since it's a border */ - height: 50%; + height: 40%; border-left: solid 1px color('base-light'); transform: translateY(-50%); } From 1cf536ab3e8f7358a95fefe948258763ed717202 Mon Sep 17 00:00:00 2001 From: Rachid Mrad Date: Mon, 17 Jun 2024 15:33:14 -0400 Subject: [PATCH 16/16] Add comment on Start new domain request button --- src/registrar/templates/home.html | 6 +++++- src/registrar/views/domain_request.py | 12 ------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/registrar/templates/home.html b/src/registrar/templates/home.html index 15261440d..f93159f01 100644 --- a/src/registrar/templates/home.html +++ b/src/registrar/templates/home.html @@ -15,7 +15,11 @@ {% endblock %}

Manage your domains

- + {% 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 %}

diff --git a/src/registrar/views/domain_request.py b/src/registrar/views/domain_request.py index b71c0c76d..77699e17a 100644 --- a/src/registrar/views/domain_request.py +++ b/src/registrar/views/domain_request.py @@ -107,12 +107,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): Step.ABOUT_YOUR_ORGANIZATION: lambda w: w.from_model("show_about_your_organization", False), } - def get_session_data(self, request): - """Retrieve 'global' data from session: - The homepage sets new_request to True for the first Create domain request.""" - is_a_new_request = self.request.session.get("new_request", "No data found") - return is_a_new_request - def __init__(self): super().__init__() self.steps = StepsHelper(self) @@ -445,12 +439,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView): # We need to avoid creating a new domain request if the user # clicks the back button self.request.session["new_request"] = False - else: - # Reset the above logic to be extra safe; - # we do not want to stumble into a situation where a user - # unknowingly overwrites when she thinks she's working on a - # new request - self.request.session["new_request"] = True self.steps.current = step return redirect(reverse(f"{self.URL_NAMESPACE}:{step}"))