mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
Cleanup
This commit is contained in:
parent
84febbbde3
commit
9c230fcfa7
3 changed files with 8 additions and 16 deletions
|
@ -26,7 +26,7 @@ class CheckUserProfileMiddleware:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
def process_view(self, request, view_func, view_args, view_kwargs):
|
def process_view(self, request, view_func, view_args, view_kwargs):
|
||||||
"""Runs pre-processing logic for each view. Checks for the
|
"""Runs pre-processing logic for each view. Checks for the
|
||||||
finished_setup flag on the current user. If they haven't done so,
|
finished_setup flag on the current user. If they haven't done so,
|
||||||
then we redirect them to the finish setup page."""
|
then we redirect them to the finish setup page."""
|
||||||
# Check that the user is "opted-in" to the profile feature flag
|
# Check that the user is "opted-in" to the profile feature flag
|
||||||
|
|
|
@ -16,9 +16,7 @@ from registrar.models import (
|
||||||
from registrar.views.utility.permission_views import UserProfilePermissionView
|
from registrar.views.utility.permission_views import UserProfilePermissionView
|
||||||
from waffle.decorators import flag_is_active, waffle_flag
|
from waffle.decorators import flag_is_active, waffle_flag
|
||||||
|
|
||||||
from registrar.templatetags.url_helpers import public_site_url
|
|
||||||
from registrar.models.utility.generic_helper import replace_url_queryparams
|
from registrar.models.utility.generic_helper import replace_url_queryparams
|
||||||
from django.utils.safestring import mark_safe
|
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
from django.views.decorators.csrf import csrf_protect
|
from django.views.decorators.csrf import csrf_protect
|
||||||
|
|
||||||
|
@ -102,8 +100,6 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
form_class = FinishSetupProfileForm
|
form_class = FinishSetupProfileForm
|
||||||
model = Contact
|
model = Contact
|
||||||
|
|
||||||
redirect_type = None
|
|
||||||
|
|
||||||
class RedirectType(Enum):
|
class RedirectType(Enum):
|
||||||
"""
|
"""
|
||||||
Enums for each type of redirection. Enforces behaviour on `get_redirect_url()`.
|
Enums for each type of redirection. Enforces behaviour on `get_redirect_url()`.
|
||||||
|
@ -120,6 +116,9 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
BACK_TO_SELF = "back_to_self"
|
BACK_TO_SELF = "back_to_self"
|
||||||
COMPLETE_SETUP = "complete_setup"
|
COMPLETE_SETUP = "complete_setup"
|
||||||
|
|
||||||
|
redirect_type = None
|
||||||
|
all_redirect_types = [r.value for r in RedirectType]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
@ -153,9 +152,7 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
|
|
||||||
# Update redirect type based on the query parameter if present
|
# Update redirect type based on the query parameter if present
|
||||||
redirect_type = request.GET.get("redirect", self.RedirectType.BACK_TO_SELF.value)
|
redirect_type = request.GET.get("redirect", self.RedirectType.BACK_TO_SELF.value)
|
||||||
|
if redirect_type in self.all_redirect_types:
|
||||||
all_redirect_types = [r.value for r in self.RedirectType]
|
|
||||||
if redirect_type in all_redirect_types:
|
|
||||||
self.redirect_type = self.RedirectType(redirect_type)
|
self.redirect_type = self.RedirectType(redirect_type)
|
||||||
else:
|
else:
|
||||||
# If the redirect type is undefined, then we assume that
|
# If the redirect type is undefined, then we assume that
|
||||||
|
@ -178,11 +175,8 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
# Logic for when the 'Save' button is clicked
|
# Logic for when the 'Save' button is clicked
|
||||||
self.redirect_type = self.RedirectType.COMPLETE_SETUP
|
self.redirect_type = self.RedirectType.COMPLETE_SETUP
|
||||||
elif "contact_setup_submit_button" in request.POST:
|
elif "contact_setup_submit_button" in request.POST:
|
||||||
if "redirect_viewname" in self.session:
|
specific_redirect = "redirect_viewname" in self.session
|
||||||
self.redirect_type = self.RedirectType.TO_SPECIFIC_PAGE
|
self.redirect_type = self.RedirectType.TO_SPECIFIC_PAGE if specific_redirect else self.RedirectType.HOME
|
||||||
else:
|
|
||||||
self.redirect_type = self.RedirectType.HOME
|
|
||||||
|
|
||||||
return self.form_valid(form)
|
return self.form_valid(form)
|
||||||
else:
|
else:
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
@ -211,7 +205,7 @@ class FinishProfileSetupView(UserProfileView):
|
||||||
base_url = ""
|
base_url = ""
|
||||||
try:
|
try:
|
||||||
if self.redirect_type in self_redirect:
|
if self.redirect_type in self_redirect:
|
||||||
base_url = reverse("finish-user-profile-setup", kwargs={"pk": self.object.pk})
|
base_url = reverse("finish-user-profile-setup")
|
||||||
elif self.redirect_type == self.RedirectType.TO_SPECIFIC_PAGE:
|
elif self.redirect_type == self.RedirectType.TO_SPECIFIC_PAGE:
|
||||||
# We only allow this session value to use viewnames,
|
# We only allow this session value to use viewnames,
|
||||||
# because this restricts what can be redirected to.
|
# because this restricts what can be redirected to.
|
||||||
|
|
|
@ -8,8 +8,6 @@ from registrar.models import (
|
||||||
DomainInvitation,
|
DomainInvitation,
|
||||||
DomainInformation,
|
DomainInformation,
|
||||||
UserDomainRole,
|
UserDomainRole,
|
||||||
Contact,
|
|
||||||
User,
|
|
||||||
)
|
)
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue