This commit is contained in:
CocoByte 2024-07-03 18:42:49 -06:00
parent 195d3287f3
commit f0af949783
No known key found for this signature in database
GPG key ID: BBFAA2526384C97F

View file

@ -108,6 +108,8 @@ 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")
logger.info(form.initial)
return super().form_invalid(form)
def form_valid(self, form):
@ -119,17 +121,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
# superclass has the redirect
return super().form_valid(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.")
logger.info("got here, now rendering response")
form.initial['redirect'] = form.data.get('redirect')
logger.info(form.initial)
return super().form_invalid(form)
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
@ -190,4 +182,4 @@ class FinishProfileSetupView(UserProfileView):
return reverse(redirect_param)
except NoReverseMatch as err:
logger.error(f"get_redirect_url -> Could not find the specified page. Err: {err}")
return super().get_success_url()
return super().get_success_url()