Add text for expired

This commit is contained in:
zandercymatics 2024-02-02 10:57:11 -07:00
parent 9381ee3908
commit 24954ebdce
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
3 changed files with 25 additions and 3 deletions

View file

@ -1425,8 +1425,17 @@ class Domain(TimeStampedModel, DomainHelper):
logger.info("able to transition to DNS_NEEDED state")
def get_state_help_text(self) -> str:
"""Returns a str containing additional information about a given state"""
"""Returns a str containing additional information about a given state.
Returns custom content for when the domain itself is expired."""
if not self.is_expired():
help_text = Domain.State.get_help_text(self.state)
else:
# Given expired is not a physical state, but it is displayed as such,
# We need custom logic to determine this message.
help_text = (
"This domain has expired, but it is still online. "
"To renew this domain, contact help@get.gov."
)
return help_text
def _disclose_fields(self, contact: PublicContact):

View file

@ -6,7 +6,7 @@
<div class="margin-top-4 tablet:grid-col-10">
<div
class="usa-summary-box dotgov-status-box margin-top-3 padding-left-2{% if not domain.is_expired %}{% if domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %} dotgov-status-box--action-need{% endif %}{% endif %}"
class="usa-summary-box dotgov-status-box padding-bottom-0 margin-top-3 padding-left-2{% if not domain.is_expired %}{% if domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %} dotgov-status-box--action-need{% endif %}{% endif %}"
role="region"
aria-labelledby="summary-box-key-information"
>
@ -25,6 +25,11 @@
{% else %}
{{ domain.state|title }}
{% endif %}
{% if domain.get_state_help_text %}
<div class="padding-top-1 font-ui-xs">
{{ domain.get_state_help_text }}
</div>
{% endif %}
</p>
</div>
</div>

View file

@ -128,6 +128,10 @@ class LoggedInTests(TestWithUser):
"This domain has been removed and "
"is no longer registered to your organization."
)
expired_text = (
"This domain has expired, but it is still online. "
"To renew this domain, contact help@get.gov."
)
# Generate a mapping of domain names, the state, and expected messages for the subtest
test_cases = [
("deleted.gov", Domain.State.DELETED, deleted_text),
@ -135,12 +139,16 @@ class LoggedInTests(TestWithUser):
("unknown.gov", Domain.State.UNKNOWN, dns_needed_text),
("onhold.gov", Domain.State.ON_HOLD, on_hold_text),
("ready.gov", Domain.State.READY, ready_text),
("expired.gov", Domain.State.READY, expired_text)
]
for domain_name, state, expected_message in test_cases:
with self.subTest(domain_name=domain_name, state=state, expected_message=expected_message):
# Create a domain and a UserRole with the given params
test_domain, _ = Domain.objects.get_or_create(name=domain_name, state=state)
if domain_name == "expired.gov":
test_domain.expiration_date = date(2011, 10, 10)
test_domain.save()
user_role, _ = UserDomainRole.objects.get_or_create(
user=self.user, domain=test_domain, role=UserDomainRole.Roles.MANAGER
)