diff --git a/src/registrar/forms/user_profile.py b/src/registrar/forms/user_profile.py index 3dd8cbdce..682e1a5df 100644 --- a/src/registrar/forms/user_profile.py +++ b/src/registrar/forms/user_profile.py @@ -10,6 +10,8 @@ from registrar.models.utility.domain_helper import DomainHelper class UserProfileForm(forms.ModelForm): """Form for updating user profile.""" + redirect = forms.CharField(widget=forms.HiddenInput(), required=False) + class Meta: model = Contact fields = ["first_name", "middle_name", "last_name", "title", "email", "phone"] diff --git a/src/registrar/registrar_middleware.py b/src/registrar/registrar_middleware.py index f5274c99f..82ee9d0fc 100644 --- a/src/registrar/registrar_middleware.py +++ b/src/registrar/registrar_middleware.py @@ -45,6 +45,7 @@ class CheckUserProfileMiddleware: self.setup_page = reverse("finish-user-profile-setup") self.profile_page = reverse("user-profile") self.logout_page = reverse("logout") + self.regular_excluded_pages = [ self.setup_page, self.logout_page, @@ -56,6 +57,14 @@ class CheckUserProfileMiddleware: "/admin", ] + self.excluded_pages = { + self.setup_page: self.regular_excluded_pages, + self.profile_page: self.other_excluded_pages, + } + + def _get_excluded_pages(self, page): + return self.excluded_pages.get(page, []) + def __call__(self, request): response = self.get_response(request) return response @@ -72,16 +81,16 @@ class CheckUserProfileMiddleware: return None if request.user.is_authenticated: + profile_page = self.profile_page + if request.user.verification_type == User.VerificationTypeChoices.REGULAR: + profile_page = self.setup_page 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: - return self._handle_other_user_setup_not_finished(request) + return self._handle_user_setup_not_finished(request, profile_page) # Continue processing the view return None - def _handle_regular_user_setup_not_finished(self, request): + def _handle_user_setup_not_finished(self, request, profile_page): """Redirects the given user to the finish setup page. We set the "redirect" query param equal to where the user wants to go. @@ -97,7 +106,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.regular_excluded_pages): + if not any(request.path.startswith(page) for page in self._get_excluded_pages(profile_page)): # Preserve the original query parameters, and coerce them into a dict query_params = parse_qs(request.META["QUERY_STRING"]) @@ -107,23 +116,13 @@ class CheckUserProfileMiddleware: query_params["redirect"] = custom_redirect # Add our new query param, while preserving old ones - new_setup_page = replace_url_queryparams(self.setup_page, query_params) if query_params else self.setup_page + new_setup_page = replace_url_queryparams(profile_page, query_params) if query_params else profile_page return HttpResponseRedirect(new_setup_page) 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.other_excluded_pages): - return HttpResponseRedirect(self.profile_page) - else: - # Process the view as normal - return None - class CheckPortfolioMiddleware: """ diff --git a/src/registrar/templates/domain_request_intro.html b/src/registrar/templates/domain_request_intro.html index 2bfeeeef1..370ea2b2b 100644 --- a/src/registrar/templates/domain_request_intro.html +++ b/src/registrar/templates/domain_request_intro.html @@ -18,7 +18,7 @@ completing your domain request might take around 15 minutes.
{% if has_profile_feature_flag %}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 your profile to make updates.
+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 your profile to make updates.
{% include "includes/profile_information.html" with user=user%} {% endif %} diff --git a/src/registrar/templates/finish_profile_setup.html b/src/registrar/templates/finish_profile_setup.html index f8070551b..6e35ad5da 100644 --- a/src/registrar/templates/finish_profile_setup.html +++ b/src/registrar/templates/finish_profile_setup.html @@ -5,7 +5,7 @@ {# Disable the redirect #} {% block logo %} - {% include "includes/gov_extended_logo.html" with logo_clickable=confirm_changes %} + {% include "includes/gov_extended_logo.html" with logo_clickable=user_finished_setup %} {% endblock %} {# Add the new form #} @@ -16,5 +16,5 @@ {% endblock content_bottom %} {% block footer %} - {% include "includes/footer.html" with show_manage_your_domains=confirm_changes %} + {% include "includes/footer.html" with show_manage_your_domains=user_finished_setup %} {% endblock footer %} diff --git a/src/registrar/templates/includes/finish_profile_form.html b/src/registrar/templates/includes/finish_profile_form.html index a40534b48..d43ff812c 100644 --- a/src/registrar/templates/includes/finish_profile_form.html +++ b/src/registrar/templates/includes/finish_profile_form.html @@ -33,6 +33,8 @@ Your contact information + + {% with show_edit_button=True show_readonly=True group_classes="usa-form-editable usa-form-editable--no-border padding-top-2" %} {% input_with_errors form.full_name %} {% endwith %} @@ -78,7 +80,7 @@ - {% if confirm_changes and going_to_specific_page %} + {% if user_finished_setup and going_to_specific_page %} diff --git a/src/registrar/templates/includes/profile_form.html b/src/registrar/templates/includes/profile_form.html index cb3e734bf..966b92b01 100644 --- a/src/registrar/templates/includes/profile_form.html +++ b/src/registrar/templates/includes/profile_form.html @@ -19,6 +19,9 @@