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
|
||||
```
|
||||
|
||||
### 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
|
||||
|
||||
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'
|
||||
on GETs of the RequestingEntityForm."""
|
||||
if obj is None:
|
||||
print("!!!! FROM_DATABASE receive a NONE object")
|
||||
return {}
|
||||
# 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
|
||||
print(f"**** FROM_DATABASE BEFORE modification: {domain_request_dict}")
|
||||
# set sub_organization to 'other' if is_requesting_new_suborganization is True
|
||||
if isinstance(obj, DomainRequest) and obj.is_requesting_new_suborganization():
|
||||
domain_request_dict["sub_organization"] = "other"
|
||||
|
||||
print(f"***** FROM_DATABASE: AFTER modification: {domain_request_dict}")
|
||||
return domain_request_dict
|
||||
|
||||
def clean_sub_organization(self):
|
||||
|
@ -165,7 +162,6 @@ class RequestingEntityForm(RegistrarForm):
|
|||
def clean(self):
|
||||
"""Custom clean implementation to handle our desired logic flow for suborganization."""
|
||||
cleaned_data = super().clean()
|
||||
print(f"**** CLEAN: data before: {cleaned_data}")
|
||||
|
||||
# Get the cleaned data
|
||||
suborganization = cleaned_data.get("sub_organization")
|
||||
|
@ -193,7 +189,6 @@ class RequestingEntityForm(RegistrarForm):
|
|||
elif not self.data and getattr(self, "_original_suborganization", None) == "other":
|
||||
self.cleaned_data["sub_organization"] = self._original_suborganization
|
||||
|
||||
print(f"**** CLEAN: clean data after: {cleaned_data}")
|
||||
return cleaned_data
|
||||
|
||||
|
||||
|
|
|
@ -245,16 +245,16 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
is called in the validate function on the request/domain page
|
||||
|
||||
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()
|
||||
# req = commands.CheckDomain([domain_name])
|
||||
# return registry.send(req, cleaned=True).res_data[0].avail
|
||||
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()
|
||||
req = commands.CheckDomain([domain_name])
|
||||
return registry.send(req, cleaned=True).res_data[0].avail
|
||||
|
||||
@classmethod
|
||||
def registered(cls, domain: str) -> bool:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue