Add in documentation and updated code

This commit is contained in:
Rebecca Hsieh 2025-03-10 17:19:56 -07:00
parent 55a101b7f6
commit a233420af9
No known key found for this signature in database
4 changed files with 22 additions and 50 deletions

View file

@ -206,39 +206,30 @@ class DomainRequestWizard(TemplateView):
else:
raise ValueError("Invalid value for User")
print("****** LINE ABOVE ******")
if self.has_pk():
try:
self._domain_request = DomainRequest.objects.get(
creator=creator,
pk=self.kwargs.get("domain_request_pk"),
)
print(f"@@@@ Retrieved existing DomainRequest: {self._domain_request}")
return self._domain_request
except DomainRequest.DoesNotExist:
logger.debug("DomainRequest id %s did not have a DomainRequest" % self.kwargs.get("domain_request_pk"))
print("****** LINE BELOW ******")
# If a user is creating a request, we assume that perms are handled upstream
if self.request.user.is_org_user(self.request):
portfolio = self.request.session.get("portfolio")
print(f"@@@@ User is an org user. Portfolio retrieved: {portfolio}")
self._domain_request = DomainRequest.objects.create(
creator=self.request.user,
portfolio=portfolio,
)
print(f"@@@@ New DomainRequest created: {self._domain_request}")
# Question for reviewers: we should probably be doing this right?
if portfolio and not self._domain_request.generic_org_type:
print(f"@@@@ Set generic_org_type to {portfolio.organization_type}")
self._domain_request.generic_org_type = portfolio.organization_type
self._domain_request.save()
print(f"@@@@ Updated DomainRequest: {self._domain_request}")
else:
# Should not see this statement wanyway bc we are creating w portfolio
print("XXXX User is not an org user - create domain request w/o portfolio")
self._domain_request = DomainRequest.objects.create(creator=self.request.user)
print(f"XXXX New DomainRequest created for non-org user: {self._domain_request}")
return self._domain_request
@property
@ -265,11 +256,8 @@ class DomainRequestWizard(TemplateView):
def done(self):
"""Called when the user clicks the submit button, if all forms are valid."""
print("***** DONE: Submitting")
self.domain_request.submit() # change the status to submitted
print("***** DONE: Saving")
self.domain_request.save()
print(f"***** DONE Finished saving, domain request is {self.domain_request}")
logger.debug("Domain Request object saved: %s", self.domain_request.id)
return redirect(reverse(f"{self.URL_NAMESPACE}:finished"))
@ -452,14 +440,6 @@ class DomainRequestWizard(TemplateView):
def get_context_data(self):
"""Define context for access on all wizard pages."""
print("in get_context_data")
# current_url = self.request.get_full_path()
# print("current_url is", current_url)
# print("reverse", reverse(f"{self.URL_NAMESPACE}:finished"))
# if current_url == reverse(f"{self.URL_NAMESPACE}:finished"):
# return None
# print("past the check")
requested_domain_name = None
if self.domain_request.requested_domain is not None:
requested_domain_name = self.domain_request.requested_domain.name
@ -532,11 +512,9 @@ class DomainRequestWizard(TemplateView):
forms = self.get_forms(use_post=True)
if self.is_valid(forms):
print("YYYYY should come into here bc it's valid")
# always save progress
self.save(forms)
else:
print("XXXXXX should not come into here to call get context data again bc it's valid")
context = self.get_context_data()
context["forms"] = forms
return render(request, self.template_name, context)
@ -616,18 +594,7 @@ class RequestingEntity(DomainRequestWizard):
"suborganization_state_territory": None,
}
)
print("!!!!! DomainRequest Instance:", self.domain_request)
print("!!!!! Cleaned Data for RequestingEntityForm:", requesting_entity_form.cleaned_data)
print("!!!!! Suborganization Data Before Submit: Requested:", cleaned_data.get("requested_suborganization"))
print("!!!!! City:", cleaned_data.get("suborganization_city"))
print("!!!!! State/Territory:", cleaned_data.get("suborganization_state_territory"))
print("$$$$$ DomainRequest before form save:", self.domain_request)
print("$$$$$ forms is", forms)
# So maybe bc it's saving 2 forms, one actually gets saved and the other becomes a draft?
# super().save(forms[0])
super().save(forms)
print("$$$$$ After super().save() called, domain request instance:", self.domain_request)
# super().save(forms)
class PortfolioAdditionalDetails(DomainRequestWizard):
@ -849,11 +816,9 @@ class Finished(DomainRequestWizard):
forms = [] # type: ignore
def get(self, request, *args, **kwargs):
context = self.get_context_data()
context["domain_request_id"] = self.domain_request.id
# clean up this wizard session, because we are done with it
del self.storage
return render(self.request, self.template_name, context)
return render(self.request, self.template_name)
@grant_access(IS_DOMAIN_REQUEST_CREATOR, HAS_PORTFOLIO_DOMAIN_REQUESTS_EDIT)