Text updates to success and error messages (#1593)

* Text updates to error messages

* Error message text updates

* Error message text updates

* Update to success message text for name server update

* Update to DS data removal warning text

* Success message text updates

* typo fix

* Text updates for success messages

* Update 403 text

* Update 500 error text

* Using example.com instead of city.com

* Putting the period outside the link

* Updated name server minimum error text

* Trying to fix python errors

* Update name server minimum text

* Update errors.py

* Trying to fix python errors

* Update errors.py

* Making error messages agree

* Minor text change

* Fix black error message formatting

* Fixed tests and reformatted

* One last fix?

---------

Co-authored-by: Neil Martinsen-Burrell <neil.martinsen-burrell@gsa.gov>
This commit is contained in:
Michelle Rago 2024-01-09 09:19:51 -05:00 committed by GitHub
parent f8d2898836
commit e2af9ac153
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 41 additions and 37 deletions

View file

@ -29,7 +29,7 @@ DOMAIN_API_MESSAGES = {
"unavailable": mark_safe( # nosec "unavailable": mark_safe( # nosec
"That domain isnt available. " "That domain isnt available. "
"<a class='usa-link' href='{}' target='_blank'>" "<a class='usa-link' href='{}' target='_blank'>"
"Read more about choosing your .gov domain.</a>".format(public_site_url("domains/choosing")) "Read more about choosing your .gov domain</a>.".format(public_site_url("domains/choosing"))
), ),
"invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).", "invalid": "Enter a domain using only letters, numbers, or hyphens (though we don't recommend using hyphens).",
"success": "That domain is available! Well try to give you the domain you want, \ "success": "That domain is available! Well try to give you the domain you want, \

View file

@ -51,7 +51,7 @@ class ViewsTest(TestCase):
# assert # assert
self.assertEqual(response.status_code, 500) self.assertEqual(response.status_code, 500)
self.assertTemplateUsed(response, "500.html") self.assertTemplateUsed(response, "500.html")
self.assertIn("server error", response.content.decode("utf-8")) self.assertIn("Server error", response.content.decode("utf-8"))
def test_login_callback_reads_next(self, mock_client): def test_login_callback_reads_next(self, mock_client):
# setup # setup

View file

@ -1251,7 +1251,7 @@ admin.site.register(models.DomainInformation, DomainInformationAdmin)
admin.site.register(models.Domain, DomainAdmin) admin.site.register(models.Domain, DomainAdmin)
admin.site.register(models.DraftDomain, DraftDomainAdmin) admin.site.register(models.DraftDomain, DraftDomainAdmin)
# Host and HostIP removed from django admin because changes in admin # Host and HostIP removed from django admin because changes in admin
# do not propogate to registry and logic not applied # do not propagate to registry and logic not applied
# admin.site.register(models.Host, MyHostAdmin) # admin.site.register(models.Host, MyHostAdmin)
admin.site.register(models.Website, WebsiteAdmin) admin.site.register(models.Website, WebsiteAdmin)
admin.site.register(models.PublicContact, AuditedAdmin) admin.site.register(models.PublicContact, AuditedAdmin)

View file

@ -262,7 +262,7 @@ class OrganizationContactForm(RegistrarForm):
validators=[ validators=[
RegexValidator( RegexValidator(
"^[0-9]{5}(?:-[0-9]{4})?$|^$", "^[0-9]{5}(?:-[0-9]{4})?$|^$",
message="Enter a zip code in the required format, like 12345 or 12345-6789.", message="Enter a zip code in the form of 12345 or 12345-6789.",
) )
], ],
) )
@ -353,7 +353,7 @@ class CurrentSitesForm(RegistrarForm):
required=False, required=False,
label="Public website", label="Public website",
error_messages={ error_messages={
"invalid": ("Enter your organization's current website in the required format, like www.city.com.") "invalid": ("Enter your organization's current website in the required format, like example.com.")
}, },
) )
@ -543,7 +543,7 @@ class YourContactForm(RegistrarForm):
) )
phone = PhoneNumberField( phone = PhoneNumberField(
label="Phone", label="Phone",
error_messages={"required": "Enter your phone number."}, error_messages={"invalid": "Enter a valid 10-digit phone number.", "required": "Enter your phone number."},
) )
@ -574,7 +574,10 @@ class OtherContactsForm(RegistrarForm):
) )
phone = PhoneNumberField( phone = PhoneNumberField(
label="Phone", label="Phone",
error_messages={"required": "Enter a phone number for this contact."}, error_messages={
"invalid": "Enter a valid 10-digit phone number.",
"required": "Enter a phone number for this contact.",
},
) )
def clean(self): def clean(self):

View file

@ -59,7 +59,7 @@ class DomainNameserverForm(forms.Form):
# add custom error messages # add custom error messages
self.fields["server"].error_messages.update( self.fields["server"].error_messages.update(
{ {
"required": "A minimum of 2 name servers are required.", "required": "At least two name servers are required.",
} }
) )

View file

@ -9,10 +9,10 @@
<div class="grid-row grow-gap"> <div class="grid-row grow-gap">
<div class="tablet:grid-col-6 usa-prose margin-bottom-3"> <div class="tablet:grid-col-6 usa-prose margin-bottom-3">
<h1> <h1>
{% translate "You do not have the right permissions to view this page." %} {% translate "You're not authorized to view this page." %}
</h1> </h1>
<h2> <h2>
{% translate "Status 403" %} {% translate "403 error" %}
</h2> </h2>
@ -23,7 +23,7 @@
{% endif %} {% endif %}
<p> <p>
You must be an authorized user and need to be signed in to view this page. You must be an authorized user and need to be signed in to view this page.
<a href="{% url 'login' %}"> Try logging in again</a>. <a href="{% url 'login' %}"> Try signing in again</a>.
</p> </p>
<p> <p>
If you'd like help with this error <a class="usa-link" rel="noopener noreferrer" target="_blank" href="{% public_site_url 'contact' %}">contact us</a>. If you'd like help with this error <a class="usa-link" rel="noopener noreferrer" target="_blank" href="{% public_site_url 'contact' %}">contact us</a>.

View file

@ -9,10 +9,10 @@
<div class="grid-row grid-gap"> <div class="grid-row grid-gap">
<div class="tablet:grid-col-6 usa-prose margin-bottom-3"> <div class="tablet:grid-col-6 usa-prose margin-bottom-3">
<h1> <h1>
{% translate "We're having some trouble" %} {% translate "We're having some trouble." %}
</h1> </h1>
<h2> <h2>
{% translate "Status 500 server error" %} {% translate "500 error" %}
</h2> </h2>
{% if friendly_message %} {% if friendly_message %}
<p>{{ friendly_message }}</p> <p>{{ friendly_message }}</p>

View file

@ -114,7 +114,7 @@
aria-describedby="Your DNSSEC records will be deleted from the registry." aria-describedby="Your DNSSEC records will be deleted from the registry."
data-force-action data-force-action
> >
{% include 'includes/modal.html' with cancel_button_resets_ds_form=True modal_heading="Warning: You are about to remove all DS records on your domain" modal_description="To fully disable DNSSEC: In addition to removing your DS records here youll also need to delete the DS records at your DNS host. To avoid causing your domain to appear offline you should wait to delete your DS records at your DNS host until the Time to Live (TTL) expires. This is often less than 24 hours, but confirm with your provider." modal_button=modal_button|safe %} {% include 'includes/modal.html' with cancel_button_resets_ds_form=True modal_heading="Warning: You are about to remove all DS records on your domain." modal_description="To fully disable DNSSEC: In addition to removing your DS records here, youll need to delete the DS records at your DNS host. To avoid causing your domain to appear offline, you should wait to delete your DS records at your DNS host until the Time to Live (TTL) expires. This is often less than 24 hours, but confirm with your provider." modal_button=modal_button|safe %}
</div> </div>
{% endblock %} {# domain_content #} {% endblock %} {# domain_content #}

View file

@ -30,7 +30,7 @@ class TestFormValidation(MockEppLib):
form = OrganizationContactForm(data={"zipcode": "nah"}) form = OrganizationContactForm(data={"zipcode": "nah"})
self.assertEqual( self.assertEqual(
form.errors["zipcode"], form.errors["zipcode"],
["Enter a zip code in the required format, like 12345 or 12345-6789."], ["Enter a zip code in the form of 12345 or 12345-6789."],
) )
def test_org_contact_zip_valid(self): def test_org_contact_zip_valid(self):
@ -42,7 +42,7 @@ class TestFormValidation(MockEppLib):
form = CurrentSitesForm(data={"website": "nah"}) form = CurrentSitesForm(data={"website": "nah"})
self.assertEqual( self.assertEqual(
form.errors["website"], form.errors["website"],
["Enter your organization's current website in the required format, like www.city.com."], ["Enter your organization's current website in the required format, like example.com."],
) )
def test_website_valid(self): def test_website_valid(self):
@ -207,7 +207,7 @@ class TestFormValidation(MockEppLib):
def test_your_contact_phone_invalid(self): def test_your_contact_phone_invalid(self):
"""Must be a valid phone number.""" """Must be a valid phone number."""
form = YourContactForm(data={"phone": "boss@boss"}) form = YourContactForm(data={"phone": "boss@boss"})
self.assertTrue(form.errors["phone"][0].startswith("Enter a valid phone number ")) self.assertTrue(form.errors["phone"][0].startswith("Enter a valid 10-digit phone number."))
def test_other_contact_email_invalid(self): def test_other_contact_email_invalid(self):
"""must be a valid email address.""" """must be a valid email address."""
@ -220,7 +220,7 @@ class TestFormValidation(MockEppLib):
def test_other_contact_phone_invalid(self): def test_other_contact_phone_invalid(self):
"""Must be a valid phone number.""" """Must be a valid phone number."""
form = OtherContactsForm(data={"phone": "super@boss"}) form = OtherContactsForm(data={"phone": "super@boss"})
self.assertTrue(form.errors["phone"][0].startswith("Enter a valid phone number ")) self.assertTrue(form.errors["phone"][0].startswith("Enter a valid 10-digit phone number."))
def test_requirements_form_blank(self): def test_requirements_form_blank(self):
"""Requirements box unchecked is an error.""" """Requirements box unchecked is an error."""

View file

@ -10,7 +10,7 @@ class TestNameserverError(TestCase):
def test_with_no_ip(self): def test_with_no_ip(self):
"""Test NameserverError when no ip address is passed""" """Test NameserverError when no ip address is passed"""
nameserver = "nameserver val" nameserver = "nameserver val"
expected = "Using your domain for a name server requires an IP address" expected = "Using your domain for a name server requires an IP address."
nsException = NameserverError(code=nsErrorCodes.MISSING_IP, nameserver=nameserver) nsException = NameserverError(code=nsErrorCodes.MISSING_IP, nameserver=nameserver)
self.assertEqual(nsException.message, expected) self.assertEqual(nsException.message, expected)
@ -20,7 +20,7 @@ class TestNameserverError(TestCase):
"""Test NameserverError when no ip address """Test NameserverError when no ip address
and no nameserver is passed""" and no nameserver is passed"""
nameserver = "nameserver val" nameserver = "nameserver val"
expected = "Too many hosts provided, you may not have more than 13 nameservers." expected = "You can't have more than 13 nameservers."
nsException = NameserverError(code=nsErrorCodes.TOO_MANY_HOSTS, nameserver=nameserver) nsException = NameserverError(code=nsErrorCodes.TOO_MANY_HOSTS, nameserver=nameserver)
self.assertEqual(nsException.message, expected) self.assertEqual(nsException.message, expected)

View file

@ -1974,7 +1974,7 @@ class TestDomainNameservers(TestDomainOverview):
# the required field. form requires a minimum of 2 name servers # the required field. form requires a minimum of 2 name servers
self.assertContains( self.assertContains(
result, result,
"A minimum of 2 name servers are required.", "At least two name servers are required.",
count=2, count=2,
status_code=200, status_code=200,
) )
@ -2215,7 +2215,7 @@ class TestDomainNameservers(TestDomainOverview):
# once around each required field. # once around each required field.
self.assertContains( self.assertContains(
result, result,
"A minimum of 2 name servers are required.", "At least two name servers are required.",
count=4, count=4,
status_code=200, status_code=200,
) )

View file

@ -44,8 +44,8 @@ class GenericError(Exception):
_error_mapping = { _error_mapping = {
GenericErrorCodes.CANNOT_CONTACT_REGISTRY: ( GenericErrorCodes.CANNOT_CONTACT_REGISTRY: (
"Were experiencing a system connection error. Please wait a few minutes " "Were experiencing a system error. Please wait a few minutes "
"and try again. If you continue to receive this error after a few tries, " "and try again. If you continue to get this error, "
"contact help@get.gov." "contact help@get.gov."
), ),
GenericErrorCodes.GENERIC_ERROR: ("Value entered was wrong."), GenericErrorCodes.GENERIC_ERROR: ("Value entered was wrong."),
@ -97,13 +97,15 @@ class NameserverError(Exception):
""" """
_error_mapping = { _error_mapping = {
NameserverErrorCodes.MISSING_IP: ("Using your domain for a name server requires an IP address"), NameserverErrorCodes.MISSING_IP: ("Using your domain for a name server requires an IP address."),
NameserverErrorCodes.GLUE_RECORD_NOT_ALLOWED: ("Name server address does not match domain name"), NameserverErrorCodes.GLUE_RECORD_NOT_ALLOWED: ("Name server address does not match domain name"),
NameserverErrorCodes.INVALID_IP: ("{}: Enter an IP address in the required format."), NameserverErrorCodes.INVALID_IP: ("{}: Enter an IP address in the required format."),
NameserverErrorCodes.TOO_MANY_HOSTS: ("Too many hosts provided, you may not have more than 13 nameservers."), NameserverErrorCodes.TOO_MANY_HOSTS: ("You can't have more than 13 nameservers."),
NameserverErrorCodes.MISSING_HOST: ("Name server must be provided to enter IP address."), NameserverErrorCodes.MISSING_HOST: ("You must provide a name server to enter an IP address."),
NameserverErrorCodes.INVALID_HOST: ("Enter a name server in the required format, like ns1.example.com"), NameserverErrorCodes.INVALID_HOST: ("Enter a name server in the required format, like ns1.example.com"),
NameserverErrorCodes.DUPLICATE_HOST: ("Remove duplicate entry"), NameserverErrorCodes.DUPLICATE_HOST: (
"You already entered this name server address. Name server addresses must be unique."
),
NameserverErrorCodes.BAD_DATA: ( NameserverErrorCodes.BAD_DATA: (
"Theres something wrong with the name server information you provided. " "Theres something wrong with the name server information you provided. "
"If you need help email us at help@get.gov." "If you need help email us at help@get.gov."
@ -156,8 +158,8 @@ class DsDataError(Exception):
), ),
DsDataErrorCodes.INVALID_DIGEST_SHA1: ("SHA-1 digest must be exactly 40 characters."), DsDataErrorCodes.INVALID_DIGEST_SHA1: ("SHA-1 digest must be exactly 40 characters."),
DsDataErrorCodes.INVALID_DIGEST_SHA256: ("SHA-256 digest must be exactly 64 characters."), DsDataErrorCodes.INVALID_DIGEST_SHA256: ("SHA-256 digest must be exactly 64 characters."),
DsDataErrorCodes.INVALID_DIGEST_CHARS: ("Digest must contain only alphanumeric characters [0-9,a-f]."), DsDataErrorCodes.INVALID_DIGEST_CHARS: ("Digest must contain only alphanumeric characters (0-9, a-f)."),
DsDataErrorCodes.INVALID_KEYTAG_SIZE: ("Key tag must be less than 65535"), DsDataErrorCodes.INVALID_KEYTAG_SIZE: ("Key tag must be less than 65535."),
} }
def __init__(self, *args, code=None, **kwargs): def __init__(self, *args, code=None, **kwargs):
@ -187,7 +189,7 @@ class SecurityEmailError(Exception):
""" """
_error_mapping = { _error_mapping = {
SecurityEmailErrorCodes.BAD_DATA: ("Enter an email address in the required format, like name@example.com.") SecurityEmailErrorCodes.BAD_DATA: ("Enter an email address in the required format, " "like name@example.com."),
} }
def __init__(self, *args, code=None, **kwargs): def __init__(self, *args, code=None, **kwargs):

View file

@ -196,7 +196,7 @@ class DomainOrgNameAddressView(DomainFormBaseView):
"""The form is valid, save the organization name and mailing address.""" """The form is valid, save the organization name and mailing address."""
form.save() form.save()
messages.success(self.request, "The organization information has been updated.") messages.success(self.request, "The organization information for this domain has been updated.")
# superclass has the redirect # superclass has the redirect
return super().form_valid(form) return super().form_valid(form)
@ -348,9 +348,8 @@ class DomainNameserversView(DomainFormBaseView):
messages.success( messages.success(
self.request, self.request,
"The name servers for this domain have been updated. " "The name servers for this domain have been updated. "
"Keep in mind that DNS changes may take some time to " "Note that DNS changes could take anywhere from a few minutes to "
"propagate across the internet. It can take anywhere " "48 hours to propagate across the internet.",
"from a few minutes to 48 hours for your changes to take place.",
) )
# superclass has the redirect # superclass has the redirect
@ -549,7 +548,7 @@ class DomainYourContactInformationView(DomainFormBaseView):
# Post to DB using values from the form # Post to DB using values from the form
form.save() form.save()
messages.success(self.request, "Your contact information for this domain has been updated.") messages.success(self.request, "Your contact information has been updated.")
# superclass has the redirect # superclass has the redirect
return super().form_valid(form) return super().form_valid(form)
@ -686,7 +685,7 @@ class DomainAddUserView(DomainFormBaseView):
) )
else: else:
if add_success: if add_success:
messages.success(self.request, f"Invited {email} to this domain.") messages.success(self.request, f"{email} has been invited to this domain.")
def _make_invitation(self, email_address: str, requester: User): def _make_invitation(self, email_address: str, requester: User):
"""Make a Domain invitation for this email and redirect with a message.""" """Make a Domain invitation for this email and redirect with a message."""