mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-11 03:59:41 +02:00
Add files with print statements
This commit is contained in:
parent
8df1a63ab4
commit
55a101b7f6
3 changed files with 49 additions and 11 deletions
|
@ -83,14 +83,16 @@ class RequestingEntityForm(RegistrarForm):
|
||||||
Overrides RegistrarForm method in order to set sub_organization to 'other'
|
Overrides RegistrarForm method in order to set sub_organization to 'other'
|
||||||
on GETs of the RequestingEntityForm."""
|
on GETs of the RequestingEntityForm."""
|
||||||
if obj is None:
|
if obj is None:
|
||||||
|
print("!!!! FROM_DATABASE receive a NONE object")
|
||||||
return {}
|
return {}
|
||||||
# get the domain request as a dict, per usual method
|
# get the domain request as a dict, per usual method
|
||||||
domain_request_dict = {name: getattr(obj, name) for name in cls.declared_fields.keys()} # type: ignore
|
domain_request_dict = {name: getattr(obj, name) for name in cls.declared_fields.keys()} # type: ignore
|
||||||
|
print(f"**** FROM_DATABASE BEFORE modification: {domain_request_dict}")
|
||||||
# set sub_organization to 'other' if is_requesting_new_suborganization is True
|
# set sub_organization to 'other' if is_requesting_new_suborganization is True
|
||||||
if isinstance(obj, DomainRequest) and obj.is_requesting_new_suborganization():
|
if isinstance(obj, DomainRequest) and obj.is_requesting_new_suborganization():
|
||||||
domain_request_dict["sub_organization"] = "other"
|
domain_request_dict["sub_organization"] = "other"
|
||||||
|
|
||||||
|
print(f"***** FROM_DATABASE: AFTER modification: {domain_request_dict}")
|
||||||
return domain_request_dict
|
return domain_request_dict
|
||||||
|
|
||||||
def clean_sub_organization(self):
|
def clean_sub_organization(self):
|
||||||
|
@ -163,6 +165,7 @@ class RequestingEntityForm(RegistrarForm):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
"""Custom clean implementation to handle our desired logic flow for suborganization."""
|
"""Custom clean implementation to handle our desired logic flow for suborganization."""
|
||||||
cleaned_data = super().clean()
|
cleaned_data = super().clean()
|
||||||
|
print(f"**** CLEAN: data before: {cleaned_data}")
|
||||||
|
|
||||||
# Get the cleaned data
|
# Get the cleaned data
|
||||||
suborganization = cleaned_data.get("sub_organization")
|
suborganization = cleaned_data.get("sub_organization")
|
||||||
|
@ -190,6 +193,7 @@ class RequestingEntityForm(RegistrarForm):
|
||||||
elif not self.data and getattr(self, "_original_suborganization", None) == "other":
|
elif not self.data and getattr(self, "_original_suborganization", None) == "other":
|
||||||
self.cleaned_data["sub_organization"] = self._original_suborganization
|
self.cleaned_data["sub_organization"] = self._original_suborganization
|
||||||
|
|
||||||
|
print(f"**** CLEAN: clean data after: {cleaned_data}")
|
||||||
return cleaned_data
|
return cleaned_data
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -245,15 +245,16 @@ class Domain(TimeStampedModel, DomainHelper):
|
||||||
is called in the validate function on the request/domain page
|
is called in the validate function on the request/domain page
|
||||||
|
|
||||||
throws- RegistryError or InvalidDomainError"""
|
throws- RegistryError or InvalidDomainError"""
|
||||||
if not cls.string_could_be_domain(domain):
|
return True
|
||||||
logger.warning("Not a valid domain: %s" % str(domain))
|
# if not cls.string_could_be_domain(domain):
|
||||||
# throw invalid domain error so that it can be caught in
|
# logger.warning("Not a valid domain: %s" % str(domain))
|
||||||
# validate_and_handle_errors in domain_helper
|
# # throw invalid domain error so that it can be caught in
|
||||||
raise errors.InvalidDomainError()
|
# # validate_and_handle_errors in domain_helper
|
||||||
|
# raise errors.InvalidDomainError()
|
||||||
|
|
||||||
domain_name = domain.lower()
|
# domain_name = domain.lower()
|
||||||
req = commands.CheckDomain([domain_name])
|
# req = commands.CheckDomain([domain_name])
|
||||||
return registry.send(req, cleaned=True).res_data[0].avail
|
# return registry.send(req, cleaned=True).res_data[0].avail
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def registered(cls, domain: str) -> bool:
|
def registered(cls, domain: str) -> bool:
|
||||||
|
|
|
@ -21,6 +21,7 @@ from registrar.models.contact import Contact
|
||||||
from registrar.models.user import User
|
from registrar.models.user import User
|
||||||
from registrar.views.utility import StepsHelper
|
from registrar.views.utility import StepsHelper
|
||||||
from registrar.utility.enums import Step, PortfolioDomainRequestStep
|
from registrar.utility.enums import Step, PortfolioDomainRequestStep
|
||||||
|
from registrar.models.utility.generic_helper import get_url_name
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -205,30 +206,39 @@ class DomainRequestWizard(TemplateView):
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid value for User")
|
raise ValueError("Invalid value for User")
|
||||||
|
|
||||||
|
print("****** LINE ABOVE ******")
|
||||||
if self.has_pk():
|
if self.has_pk():
|
||||||
try:
|
try:
|
||||||
self._domain_request = DomainRequest.objects.get(
|
self._domain_request = DomainRequest.objects.get(
|
||||||
creator=creator,
|
creator=creator,
|
||||||
pk=self.kwargs.get("domain_request_pk"),
|
pk=self.kwargs.get("domain_request_pk"),
|
||||||
)
|
)
|
||||||
|
print(f"@@@@ Retrieved existing DomainRequest: {self._domain_request}")
|
||||||
return self._domain_request
|
return self._domain_request
|
||||||
except DomainRequest.DoesNotExist:
|
except DomainRequest.DoesNotExist:
|
||||||
logger.debug("DomainRequest id %s did not have a DomainRequest" % self.kwargs.get("domain_request_pk"))
|
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 a user is creating a request, we assume that perms are handled upstream
|
||||||
if self.request.user.is_org_user(self.request):
|
if self.request.user.is_org_user(self.request):
|
||||||
portfolio = self.request.session.get("portfolio")
|
portfolio = self.request.session.get("portfolio")
|
||||||
|
print(f"@@@@ User is an org user. Portfolio retrieved: {portfolio}")
|
||||||
self._domain_request = DomainRequest.objects.create(
|
self._domain_request = DomainRequest.objects.create(
|
||||||
creator=self.request.user,
|
creator=self.request.user,
|
||||||
portfolio=portfolio,
|
portfolio=portfolio,
|
||||||
)
|
)
|
||||||
|
print(f"@@@@ New DomainRequest created: {self._domain_request}")
|
||||||
# Question for reviewers: we should probably be doing this right?
|
# Question for reviewers: we should probably be doing this right?
|
||||||
if portfolio and not self._domain_request.generic_org_type:
|
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.generic_org_type = portfolio.organization_type
|
||||||
self._domain_request.save()
|
self._domain_request.save()
|
||||||
|
print(f"@@@@ Updated DomainRequest: {self._domain_request}")
|
||||||
else:
|
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)
|
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
|
return self._domain_request
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -255,8 +265,11 @@ class DomainRequestWizard(TemplateView):
|
||||||
|
|
||||||
def done(self):
|
def done(self):
|
||||||
"""Called when the user clicks the submit button, if all forms are valid."""
|
"""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
|
self.domain_request.submit() # change the status to submitted
|
||||||
|
print("***** DONE: Saving")
|
||||||
self.domain_request.save()
|
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)
|
logger.debug("Domain Request object saved: %s", self.domain_request.id)
|
||||||
return redirect(reverse(f"{self.URL_NAMESPACE}:finished"))
|
return redirect(reverse(f"{self.URL_NAMESPACE}:finished"))
|
||||||
|
|
||||||
|
@ -439,6 +452,14 @@ class DomainRequestWizard(TemplateView):
|
||||||
|
|
||||||
def get_context_data(self):
|
def get_context_data(self):
|
||||||
"""Define context for access on all wizard pages."""
|
"""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
|
requested_domain_name = None
|
||||||
if self.domain_request.requested_domain is not None:
|
if self.domain_request.requested_domain is not None:
|
||||||
requested_domain_name = self.domain_request.requested_domain.name
|
requested_domain_name = self.domain_request.requested_domain.name
|
||||||
|
@ -511,9 +532,11 @@ class DomainRequestWizard(TemplateView):
|
||||||
|
|
||||||
forms = self.get_forms(use_post=True)
|
forms = self.get_forms(use_post=True)
|
||||||
if self.is_valid(forms):
|
if self.is_valid(forms):
|
||||||
|
print("YYYYY should come into here bc it's valid")
|
||||||
# always save progress
|
# always save progress
|
||||||
self.save(forms)
|
self.save(forms)
|
||||||
else:
|
else:
|
||||||
|
print("XXXXXX should not come into here to call get context data again bc it's valid")
|
||||||
context = self.get_context_data()
|
context = self.get_context_data()
|
||||||
context["forms"] = forms
|
context["forms"] = forms
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
@ -593,8 +616,18 @@ class RequestingEntity(DomainRequestWizard):
|
||||||
"suborganization_state_territory": None,
|
"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)
|
super().save(forms)
|
||||||
|
print("$$$$$ After super().save() called, domain request instance:", self.domain_request)
|
||||||
|
# super().save(forms)
|
||||||
|
|
||||||
|
|
||||||
class PortfolioAdditionalDetails(DomainRequestWizard):
|
class PortfolioAdditionalDetails(DomainRequestWizard):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue