mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-02 01:03:28 +02:00
Add in documentation and updated code
This commit is contained in:
parent
55a101b7f6
commit
a233420af9
4 changed files with 22 additions and 50 deletions
|
@ -207,6 +207,18 @@ Linters:
|
||||||
docker-compose exec app ./manage.py lint
|
docker-compose exec app ./manage.py lint
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Get availability for domain requests to work locally
|
||||||
|
|
||||||
|
If you're on local (localhost:8080) and want to submit a domain request, and keep getting the "We’re experiencing a system error. Please wait a few minutes and try again. If you continue to get this error, contact help@get.gov." error, you can get past the availability check by updating the available() function in registrar/models/domain.py to return True and comment everything else out - see below for reference!
|
||||||
|
|
||||||
|
```
|
||||||
|
@classmethod
|
||||||
|
def available(cls, domain: str) -> bool:
|
||||||
|
# Comment everything else out in the function
|
||||||
|
return True
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
### Testing behind logged in pages
|
### Testing behind logged in pages
|
||||||
|
|
||||||
To test behind logged in pages with external tools, like `pa11y-ci` or `OWASP Zap`, add
|
To test behind logged in pages with external tools, like `pa11y-ci` or `OWASP Zap`, add
|
||||||
|
|
|
@ -83,16 +83,13 @@ 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):
|
||||||
|
@ -165,7 +162,6 @@ 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")
|
||||||
|
@ -193,7 +189,6 @@ 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,16 +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"""
|
||||||
return True
|
|
||||||
# if not cls.string_could_be_domain(domain):
|
|
||||||
# logger.warning("Not a valid domain: %s" % str(domain))
|
|
||||||
# # throw invalid domain error so that it can be caught in
|
|
||||||
# # validate_and_handle_errors in domain_helper
|
|
||||||
# raise errors.InvalidDomainError()
|
|
||||||
|
|
||||||
# domain_name = domain.lower()
|
if not cls.string_could_be_domain(domain):
|
||||||
# req = commands.CheckDomain([domain_name])
|
logger.warning("Not a valid domain: %s" % str(domain))
|
||||||
# return registry.send(req, cleaned=True).res_data[0].avail
|
# throw invalid domain error so that it can be caught in
|
||||||
|
# validate_and_handle_errors in domain_helper
|
||||||
|
raise errors.InvalidDomainError()
|
||||||
|
|
||||||
|
domain_name = domain.lower()
|
||||||
|
req = commands.CheckDomain([domain_name])
|
||||||
|
return registry.send(req, cleaned=True).res_data[0].avail
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def registered(cls, domain: str) -> bool:
|
def registered(cls, domain: str) -> bool:
|
||||||
|
|
|
@ -206,39 +206,30 @@ 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
|
# 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
|
||||||
|
@ -265,11 +256,8 @@ 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"))
|
||||||
|
|
||||||
|
@ -452,14 +440,6 @@ 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
|
||||||
|
@ -532,11 +512,9 @@ 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)
|
||||||
|
@ -616,18 +594,7 @@ 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):
|
||||||
|
@ -849,11 +816,9 @@ class Finished(DomainRequestWizard):
|
||||||
forms = [] # type: ignore
|
forms = [] # type: ignore
|
||||||
|
|
||||||
def get(self, request, *args, **kwargs):
|
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
|
# clean up this wizard session, because we are done with it
|
||||||
del self.storage
|
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)
|
@grant_access(IS_DOMAIN_REQUEST_CREATOR, HAS_PORTFOLIO_DOMAIN_REQUESTS_EDIT)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue