Merge pull request #2425 from cisagov/nl/2420-fix-user-profile-500-error

Issue #2420 - fix 500 error on User Profile
This commit is contained in:
CuriousX 2024-07-04 12:56:24 -06:00 committed by GitHub
commit 8e71785f73
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 5 additions and 2 deletions

View file

@ -18,7 +18,7 @@
completing your domain request might take around 15 minutes.</p>
{% if has_profile_feature_flag %}
<h2>How well reach you</h2>
<p>While reviewing your domain request, we may need to reach out with questions. Well 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. Well 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>
{% include "includes/profile_information.html" with user=user%}
{% endif %}

View file

@ -602,6 +602,7 @@ class FinishUserProfileTests(TestWithUser, WebTest):
# Add a phone number
finish_setup_form = finish_setup_page.form
finish_setup_form["first_name"] = "firstname"
finish_setup_form["phone"] = "(201) 555-0123"
finish_setup_form["title"] = "CEO"
finish_setup_form["last_name"] = "example"
@ -730,6 +731,8 @@ class FinishUserProfileForOtherUsersTests(TestWithUser, WebTest):
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
# NOTE: "anage" is not a typo. It is to accomodate the fact that the "m" is uppercase in one
# instance and lowercase in the other.
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"

View file

@ -1,5 +1,4 @@
"""Views for a User Profile.
"""
import logging
@ -109,6 +108,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
"""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.")
form.initial["redirect"] = form.data.get("redirect")
return super().form_invalid(form)
def form_valid(self, form):