mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-09 22:14:43 +02:00
Respond to PR feedback
This commit is contained in:
parent
07993a8d75
commit
90557c51e8
4 changed files with 47 additions and 22 deletions
|
@ -52,7 +52,6 @@ class OrganizationTypeForm(RegistrarForm):
|
|||
|
||||
class OrganizationFederalForm(RegistrarForm):
|
||||
federal_type = forms.ChoiceField(
|
||||
required=False,
|
||||
choices=DomainApplication.BranchChoices.choices,
|
||||
widget=forms.RadioSelect,
|
||||
)
|
||||
|
@ -60,7 +59,6 @@ class OrganizationFederalForm(RegistrarForm):
|
|||
|
||||
class OrganizationElectionForm(RegistrarForm):
|
||||
is_election_board = forms.BooleanField(
|
||||
required=False,
|
||||
widget=forms.RadioSelect(
|
||||
choices=[
|
||||
(True, "Yes"),
|
||||
|
@ -120,7 +118,8 @@ class CurrentSitesForm(RegistrarForm):
|
|||
if not self.is_valid():
|
||||
return
|
||||
obj.save()
|
||||
normalized = Domain.normalize(self.cleaned_data["current_site"])
|
||||
normalized = Domain.normalize(self.cleaned_data["current_site"], blank=True)
|
||||
if normalized:
|
||||
# TODO: ability to update existing records
|
||||
obj.current_websites.create(website=normalized)
|
||||
|
||||
|
@ -142,7 +141,10 @@ class DotGovDomainForm(RegistrarForm):
|
|||
"""Adds this form's cleaned data to `obj` and saves `obj`."""
|
||||
if not self.is_valid():
|
||||
return
|
||||
normalized = Domain.normalize(self.cleaned_data["requested_domain"], "gov")
|
||||
normalized = Domain.normalize(
|
||||
self.cleaned_data["requested_domain"], "gov", blank=True
|
||||
)
|
||||
if normalized:
|
||||
requested_domain = getattr(obj, "requested_domain", None)
|
||||
if requested_domain is not None:
|
||||
requested_domain.name = normalized
|
||||
|
@ -153,7 +155,10 @@ class DotGovDomainForm(RegistrarForm):
|
|||
obj.save()
|
||||
|
||||
obj.save()
|
||||
normalized = Domain.normalize(self.cleaned_data["alternative_domain"], "gov")
|
||||
normalized = Domain.normalize(
|
||||
self.cleaned_data["alternative_domain"], "gov", blank=True
|
||||
)
|
||||
if normalized:
|
||||
# TODO: ability to update existing records
|
||||
obj.alternative_domains.create(website=normalized)
|
||||
|
||||
|
@ -252,7 +257,9 @@ class SecurityEmailForm(RegistrarForm):
|
|||
|
||||
class AnythingElseForm(RegistrarForm):
|
||||
anything_else = forms.CharField(
|
||||
required=False, label="Anything else we should know", widget=forms.Textarea()
|
||||
required=False,
|
||||
label="Anything else we should know",
|
||||
widget=forms.Textarea(),
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -93,10 +93,17 @@ class Domain(TimeStampedModel):
|
|||
DOMAIN_REGEX = re.compile(r"^(?!-)[A-Za-z0-9-]{1,63}(?<!-)\.[A-Za-z]{2,6}")
|
||||
|
||||
@classmethod
|
||||
def normalize(cls, domain: str, tld=None) -> str: # noqa: C901
|
||||
"""Return `domain` in form `<second level>.<tld>`, if possible.
|
||||
def normalize(cls, domain: str, tld=None, blank=False) -> str: # noqa: C901
|
||||
"""Return `domain` in form `<second level>.<tld>`.
|
||||
|
||||
This does not guarantee the returned string is a valid domain name."""
|
||||
Raises ValueError if string cannot be normalized.
|
||||
|
||||
This does not guarantee the returned string is a valid domain name.
|
||||
|
||||
Set `blank` to True to allow empty strings.
|
||||
"""
|
||||
if blank and len(domain.strip()) == 0:
|
||||
return ""
|
||||
cleaned = domain.lower()
|
||||
# starts with https or http
|
||||
if cleaned.startswith("https://"):
|
||||
|
|
|
@ -32,7 +32,11 @@
|
|||
<tbody>
|
||||
{% for application in domain_applications %}
|
||||
<tr>
|
||||
<th>{{ application.requested_domain.name }}</th>
|
||||
<th>
|
||||
<a href="{% url 'edit-application' application.pk %}">
|
||||
{{ application.requested_domain.name|default:"New domain request" }}
|
||||
</a>
|
||||
</th>
|
||||
<td>{{ application.status }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -602,6 +602,13 @@ class DomainApplicationTests(TestWithUser, WebTest):
|
|||
url = reverse("edit-application", kwargs={"id": application.pk})
|
||||
response = self.client.get(url)
|
||||
|
||||
# TODO: this is a sketch of each page in the wizard which needs to be tested
|
||||
# Django does not have tools sufficient for real end to end integration testing
|
||||
# (for example, USWDS moves radio buttons off screen and replaces them with
|
||||
# CSS styled "fakes" -- Django cannot determine if those are visually correct)
|
||||
# -- the best that can/should be done here is to ensure the correct values
|
||||
# are being passed to the templating engine
|
||||
|
||||
url = reverse("application_step", kwargs={"step": "organization_type"})
|
||||
response = self.client.get(url, follow=True)
|
||||
self.assertContains(response, "<input>")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue