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