mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-25 18:43:49 +02:00
merge main
This commit is contained in:
commit
af4423ce18
57 changed files with 2505 additions and 2504 deletions
|
@ -1,5 +1,4 @@
|
|||
"""Views for a User Profile.
|
||||
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
@ -9,9 +8,6 @@ from django.http import QueryDict
|
|||
from django.views.generic.edit import FormMixin
|
||||
from registrar.forms.user_profile import UserProfileForm, FinishSetupProfileForm
|
||||
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
|
||||
|
@ -25,7 +21,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
Base View for the User Profile. Handles getting and setting the User Profile
|
||||
"""
|
||||
|
||||
model = Contact
|
||||
model = User
|
||||
template_name = "profile.html"
|
||||
form_class = UserProfileForm
|
||||
base_view_name = "user-profile"
|
||||
|
@ -107,6 +103,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):
|
||||
|
@ -121,9 +118,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
def get_object(self, queryset=None):
|
||||
"""Override get_object to return the logged-in user's 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
|
||||
return self.user
|
||||
|
||||
|
||||
class FinishProfileSetupView(UserProfileView):
|
||||
|
@ -132,7 +127,7 @@ class FinishProfileSetupView(UserProfileView):
|
|||
|
||||
template_name = "finish_profile_setup.html"
|
||||
form_class = FinishSetupProfileForm
|
||||
model = Contact
|
||||
model = User
|
||||
|
||||
base_view_name = "finish-user-profile-setup"
|
||||
|
||||
|
@ -158,11 +153,11 @@ class FinishProfileSetupView(UserProfileView):
|
|||
# Get the current form and validate it
|
||||
if form.is_valid():
|
||||
self.redirect_page = False
|
||||
if "contact_setup_save_button" in request.POST:
|
||||
if "user_setup_save_button" in request.POST:
|
||||
# Logic for when the 'Save' button is clicked, which indicates
|
||||
# user should stay on this page
|
||||
self.redirect_page = False
|
||||
elif "contact_setup_submit_button" in request.POST:
|
||||
elif "user_setup_submit_button" in request.POST:
|
||||
# Logic for when the other button is clicked, which indicates
|
||||
# the user should be taken to the redirect page
|
||||
self.redirect_page = True
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue