Skip to content

Commit

Permalink
Update domain_request.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zandercymatics committed Oct 31, 2024
1 parent 37894e7 commit 20a5774
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/registrar/views/domain_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def __init__(self):
# Configure titles, wizard_conditions, unlocking_steps, and steps
self.configure_step_options()
self._domain_request = None # for caching
self.domain_request_id = None

def configure_step_options(self):
"""Changes which steps are available to the user based on self.is_portfolio.
Expand All @@ -182,7 +183,8 @@ def configure_step_options(self):

def has_pk(self):
"""Does this wizard know about a DomainRequest database record?"""
return "domain_request_id" in self.storage

return self.kwargs.get("id") is not None

def get_step_enum(self):
"""Determines which step enum we should use for the wizard"""
Expand Down Expand Up @@ -214,11 +216,10 @@ def domain_request(self) -> DomainRequest:
raise ValueError("Invalid value for User")

if self.has_pk():
id = self.storage["domain_request_id"]
try:
self._domain_request = DomainRequest.objects.get(
creator=creator,
pk=id,
pk=self.kwargs.get('id'),
)
return self._domain_request
except DomainRequest.DoesNotExist:
Expand All @@ -239,7 +240,7 @@ def domain_request(self) -> DomainRequest:
else:
self._domain_request = DomainRequest.objects.create(creator=self.request.user)

self.storage["domain_request_id"] = self._domain_request.id
self.kwargs["id"] = self._domain_request.id
return self._domain_request

@property
Expand Down Expand Up @@ -295,6 +296,7 @@ def from_model(self, attribute: str, default, *args, **kwargs):
def get(self, request, *args, **kwargs):
"""This method handles GET requests."""

self.kwargs = kwargs
if not self.is_portfolio and self.request.user.is_org_user(request):
self.is_portfolio = True
# Configure titles, wizard_conditions, unlocking_steps, and steps
Expand All @@ -307,17 +309,13 @@ def get(self, request, *args, **kwargs):
# and remove any prior wizard data from their session
if current_url == self.EDIT_URL_NAME and "id" in kwargs:
del self.storage
self.storage["domain_request_id"] = kwargs["id"]
elif "id" not in kwargs:
del self.storage

# if accessing this class directly, redirect to either to an acknowledgement
# page or to the first step in the processes (if an edit rather than a new request);
# subclasseswill NOT be redirected. The purpose of this is to allow code to
# send users "to the domain request wizard" without needing to know which view
# is first in the list of steps.
if self.__class__ == DomainRequestWizard:
print(F"what is this? {request.path_info}")
if request.path_info == self.NEW_URL_NAME:
# Clear context so the prop getter won't create a request here.
# Creating a request will be handled in the post method for the
Expand Down

0 comments on commit 20a5774

Please sign in to comment.