mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 03:58:39 +02:00
Merge branch 'main' of https://github.com/cisagov/manage.get.gov into rh/3389-env-emails
This commit is contained in:
commit
9579779e6a
8 changed files with 17 additions and 62 deletions
|
@ -68,19 +68,9 @@ def portfolio_permissions(request):
|
|||
"has_organization_requests_flag": False,
|
||||
"has_organization_members_flag": False,
|
||||
"is_portfolio_admin": False,
|
||||
"has_domain_renewal_flag": False,
|
||||
}
|
||||
try:
|
||||
portfolio = request.session.get("portfolio")
|
||||
|
||||
# These feature flags will display and doesn't depend on portfolio
|
||||
portfolio_context.update(
|
||||
{
|
||||
"has_organization_feature_flag": True,
|
||||
"has_domain_renewal_flag": request.user.has_domain_renewal_flag(),
|
||||
}
|
||||
)
|
||||
|
||||
if portfolio:
|
||||
return {
|
||||
"has_view_portfolio_permission": request.user.has_view_portfolio_permission(portfolio),
|
||||
|
@ -95,7 +85,6 @@ def portfolio_permissions(request):
|
|||
"has_organization_requests_flag": request.user.has_organization_requests_flag(),
|
||||
"has_organization_members_flag": request.user.has_organization_members_flag(),
|
||||
"is_portfolio_admin": request.user.is_portfolio_admin(portfolio),
|
||||
"has_domain_renewal_flag": request.user.has_domain_renewal_flag(),
|
||||
}
|
||||
return portfolio_context
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ from .utility.time_stamped_model import TimeStampedModel
|
|||
from .public_contact import PublicContact
|
||||
|
||||
from .user_domain_role import UserDomainRole
|
||||
from waffle.decorators import flag_is_active
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -1172,7 +1171,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
"""Return the display status of the domain."""
|
||||
if self.is_expired() and (self.state != self.State.UNKNOWN):
|
||||
return "Expired"
|
||||
elif flag_is_active(request, "domain_renewal") and self.is_expiring():
|
||||
elif self.is_expiring():
|
||||
return "Expiring soon"
|
||||
elif self.state == self.State.UNKNOWN or self.state == self.State.DNS_NEEDED:
|
||||
return "DNS needed"
|
||||
|
@ -1588,7 +1587,7 @@ class Domain(TimeStampedModel, DomainHelper):
|
|||
# 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. Complete the online renewal process to maintain access."
|
||||
elif flag_is_active(request, "domain_renewal") and self.is_expiring():
|
||||
elif self.is_expiring():
|
||||
help_text = "This domain is expiring soon. Complete the online renewal process to maintain access."
|
||||
else:
|
||||
help_text = Domain.State.get_help_text(self.state)
|
||||
|
|
|
@ -271,9 +271,6 @@ class User(AbstractUser):
|
|||
def is_portfolio_admin(self, portfolio):
|
||||
return "Admin" in self.portfolio_role_summary(portfolio)
|
||||
|
||||
def has_domain_renewal_flag(self):
|
||||
return flag_is_active_for_user(self, "domain_renewal")
|
||||
|
||||
def get_first_portfolio(self):
|
||||
permission = self.portfolio_permissions.first()
|
||||
if permission:
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
{# UNKNOWN domains would not have an expiration date and thus would show 'Expired' #}
|
||||
{% if domain.is_expired and domain.state != domain.State.UNKNOWN %}
|
||||
Expired
|
||||
{% elif has_domain_renewal_flag and domain.is_expiring %}
|
||||
{% elif domain.is_expiring %}
|
||||
Expiring soon
|
||||
{% elif domain.state == domain.State.UNKNOWN or domain.state == domain.State.DNS_NEEDED %}
|
||||
DNS needed
|
||||
|
@ -46,17 +46,17 @@
|
|||
|
||||
{% if domain.get_state_help_text %}
|
||||
<p class="margin-y-0 text-primary-darker">
|
||||
{% if has_domain_renewal_flag and domain.is_expired and is_domain_manager %}
|
||||
{% if domain.is_expired and is_domain_manager %}
|
||||
This domain has expired, but it is still online.
|
||||
{% url 'domain-renewal' pk=domain.id as url %}
|
||||
<a href="{{ url }}" class="usa-link">Renew to maintain access.</a>
|
||||
{% elif has_domain_renewal_flag and domain.is_expiring and is_domain_manager %}
|
||||
{% elif domain.is_expiring and is_domain_manager %}
|
||||
This domain will expire soon.
|
||||
{% url 'domain-renewal' pk=domain.id as url %}
|
||||
<a href="{{ url }}" class="usa-link">Renew to maintain access.</a>
|
||||
{% elif has_domain_renewal_flag and domain.is_expiring and is_portfolio_user %}
|
||||
{% elif domain.is_expiring and is_portfolio_user %}
|
||||
This domain will expire soon. Contact one of the listed domain managers to renew the domain.
|
||||
{% elif has_domain_renewal_flag and domain.is_expired and is_portfolio_user %}
|
||||
{% elif domain.is_expired and is_portfolio_user %}
|
||||
This domain has expired, but it is still online. Contact one of the listed domain managers to renew the domain.
|
||||
{% else %}
|
||||
{{ domain.get_state_help_text }}
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
{% endwith %}
|
||||
|
||||
|
||||
{% if has_domain_renewal_flag and is_domain_manager%}
|
||||
{% if is_domain_manager%}
|
||||
{% if domain.is_expiring or domain.is_expired %}
|
||||
{% with url_name="domain-renewal" %}
|
||||
{% include "includes/domain_sidenav_item.html" with item_text="Renewal form" %}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<span id="get_domains_json_url" class="display-none">{{url}}</span>
|
||||
|
||||
<!-- Org model banner (org manager can view, domain manager can edit) -->
|
||||
{% if has_domain_renewal_flag and num_expiring_domains > 0 and has_any_domains_portfolio_permission %}
|
||||
{% if num_expiring_domains > 0 and has_any_domains_portfolio_permission %}
|
||||
<section class="usa-site-alert--slim usa-site-alert--info margin-bottom-2 {% if add_class %}{{ add_class }}{% endif %}" aria-label="Site alert">
|
||||
<div class="usa-alert">
|
||||
<div class="usa-alert__body">
|
||||
|
@ -75,7 +75,7 @@
|
|||
</div>
|
||||
|
||||
<!-- Non org model banner -->
|
||||
{% if has_domain_renewal_flag and num_expiring_domains > 0 and not portfolio %}
|
||||
{% if num_expiring_domains > 0 and not portfolio %}
|
||||
<section class="usa-site-alert--slim usa-site-alert--info margin-bottom-2 {% if add_class %}{{ add_class }}{% endif %}" aria-label="Site alert">
|
||||
<div class="usa-alert">
|
||||
<div class="usa-alert__body">
|
||||
|
@ -173,7 +173,6 @@
|
|||
>Deleted</label
|
||||
>
|
||||
</div>
|
||||
{% if has_domain_renewal_flag %}
|
||||
<div class="usa-checkbox">
|
||||
<input
|
||||
class="usa-checkbox__input"
|
||||
|
@ -185,7 +184,6 @@
|
|||
<label class="usa-checkbox__label" for="filter-status-expiring"
|
||||
>Expiring soon</label>
|
||||
</div>
|
||||
{% endif %}
|
||||
</fieldset>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -477,7 +477,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.domain_with_ip.expiration_date = self.expiration_date_one_year_out()
|
||||
self.domain_with_ip.save()
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_expiring_domain_on_detail_page_as_domain_manager(self):
|
||||
"""If a user is a domain manager and their domain is expiring soon,
|
||||
user should be able to see the "Renew to maintain access" link domain overview detail box."""
|
||||
|
@ -496,7 +495,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.assertNotContains(detail_page, "DNS needed")
|
||||
self.assertNotContains(detail_page, "Expired")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
@override_flag("organization_feature", active=True)
|
||||
def test_expiring_domain_on_detail_page_in_org_model_as_a_non_domain_manager(self):
|
||||
"""In org model: If a user is NOT a domain manager and their domain is expiring soon,
|
||||
|
@ -534,7 +532,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
)
|
||||
self.assertContains(detail_page, "Contact one of the listed domain managers to renew the domain.")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
@override_flag("organization_feature", active=True)
|
||||
def test_expiring_domain_on_detail_page_in_org_model_as_a_domain_manager(self):
|
||||
"""Inorg model: If a user is a domain manager and their domain is expiring soon,
|
||||
|
@ -555,7 +552,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
)
|
||||
self.assertContains(detail_page, "Renew to maintain access")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_and_sidebar_expiring(self):
|
||||
"""If a user is a domain manager and their domain is expiring soon,
|
||||
user should be able to see Renewal Form on the sidebar."""
|
||||
|
@ -584,7 +580,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, f"Renew {self.domain_to_renew.name}")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_and_sidebar_expired(self):
|
||||
"""If a user is a domain manager and their domain is expired,
|
||||
user should be able to see Renewal Form on the sidebar."""
|
||||
|
@ -614,7 +609,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, f"Renew {self.domain_to_renew.name}")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_your_contact_info_edit(self):
|
||||
"""Checking that if a user is a domain manager they can edit the
|
||||
Your Profile portion of the Renewal Form."""
|
||||
|
@ -634,7 +628,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.assertEqual(edit_page.status_code, 200)
|
||||
self.assertContains(edit_page, "Review the details below and update any required information")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_security_email_edit(self):
|
||||
"""Checking that if a user is a domain manager they can edit the
|
||||
Security Email portion of the Renewal Form."""
|
||||
|
@ -657,7 +650,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.assertEqual(edit_page.status_code, 200)
|
||||
self.assertContains(edit_page, "A security contact should be capable of evaluating")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_domain_manager_edit(self):
|
||||
"""Checking that if a user is a domain manager they can edit the
|
||||
Domain Manager portion of the Renewal Form."""
|
||||
|
@ -677,7 +669,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
self.assertEqual(edit_page.status_code, 200)
|
||||
self.assertContains(edit_page, "Domain managers can update all information related to a domain")
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_not_expired_or_expiring(self):
|
||||
"""Checking that if the user's domain is not expired or expiring that user should not be able
|
||||
to access /renewal and that it should receive a 403."""
|
||||
|
@ -686,7 +677,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
renewal_page = self.client.get(reverse("domain-renewal", kwargs={"pk": self.domain_not_expiring.id}))
|
||||
self.assertEqual(renewal_page.status_code, 403)
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_form_does_not_appear_if_not_domain_manager(self):
|
||||
"""If user is not a domain manager and tries to access /renewal, user should receive a 403."""
|
||||
with patch.object(Domain, "is_expired", self.custom_is_expired_true), patch.object(
|
||||
|
@ -695,7 +685,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
renewal_page = self.client.get(reverse("domain-renewal", kwargs={"pk": self.domain_no_domain_manager.id}))
|
||||
self.assertEqual(renewal_page.status_code, 403)
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_ack_checkbox_not_checked(self):
|
||||
"""If user don't check the checkbox, user should receive an error message."""
|
||||
# Grab the renewal URL
|
||||
|
@ -707,7 +696,6 @@ class TestDomainDetailDomainRenewal(TestDomainOverview):
|
|||
error_message = "Check the box if you read and agree to the requirements for operating a .gov domain."
|
||||
self.assertContains(response, error_message)
|
||||
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_ack_checkbox_checked(self):
|
||||
"""If user check the checkbox and submits the form,
|
||||
user should be redirected Domain Over page with an updated by 1 year expiration date"""
|
||||
|
@ -2992,26 +2980,15 @@ class TestDomainRenewal(TestWithUser):
|
|||
pass
|
||||
super().tearDown()
|
||||
|
||||
# Remove test_without_domain_renewal_flag when domain renewal is released as a feature
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=False)
|
||||
def test_without_domain_renewal_flag(self):
|
||||
self.client.force_login(self.user)
|
||||
domains_page = self.client.get("/")
|
||||
self.assertNotContains(domains_page, "will expire soon")
|
||||
self.assertNotContains(domains_page, "Expiring soon")
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_domain_renewal_flag_single_domain(self):
|
||||
def test_domain_with_single_domain(self):
|
||||
self.client.force_login(self.user)
|
||||
domains_page = self.client.get("/")
|
||||
self.assertContains(domains_page, "One domain will expire soon")
|
||||
self.assertContains(domains_page, "Expiring soon")
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_with_domain_renewal_flag_mulitple_domains(self):
|
||||
def test_with_mulitple_domains(self):
|
||||
today = datetime.now()
|
||||
expiring_date = (today + timedelta(days=30)).strftime("%Y-%m-%d")
|
||||
self.domain_with_another_expiring, _ = Domain.objects.get_or_create(
|
||||
|
@ -3027,8 +3004,7 @@ class TestDomainRenewal(TestWithUser):
|
|||
self.assertContains(domains_page, "Expiring soon")
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=True)
|
||||
def test_with_domain_renewal_flag_no_expiring_domains(self):
|
||||
def test_with_no_expiring_domains(self):
|
||||
UserDomainRole.objects.filter(user=self.user, domain=self.domain_with_expired_date).delete()
|
||||
UserDomainRole.objects.filter(user=self.user, domain=self.domain_with_expiring_soon_date).delete()
|
||||
self.client.force_login(self.user)
|
||||
|
@ -3036,18 +3012,16 @@ class TestDomainRenewal(TestWithUser):
|
|||
self.assertNotContains(domains_page, "will expire soon")
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=True)
|
||||
@override_flag("organization_feature", active=True)
|
||||
def test_domain_renewal_flag_single_domain_w_org_feature_flag(self):
|
||||
def test_single_domain_w_org_feature_flag(self):
|
||||
self.client.force_login(self.user)
|
||||
domains_page = self.client.get("/")
|
||||
self.assertContains(domains_page, "One domain will expire soon")
|
||||
self.assertContains(domains_page, "Expiring soon")
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=True)
|
||||
@override_flag("organization_feature", active=True)
|
||||
def test_with_domain_renewal_flag_mulitple_domains_w_org_feature_flag(self):
|
||||
def test_with_mulitple_domains_w_org_feature_flag(self):
|
||||
today = datetime.now()
|
||||
expiring_date = (today + timedelta(days=31)).strftime("%Y-%m-%d")
|
||||
self.domain_with_another_expiring_org_model, _ = Domain.objects.get_or_create(
|
||||
|
@ -3063,9 +3037,8 @@ class TestDomainRenewal(TestWithUser):
|
|||
self.assertContains(domains_page, "Expiring soon")
|
||||
|
||||
@less_console_noise_decorator
|
||||
@override_flag("domain_renewal", active=True)
|
||||
@override_flag("organization_feature", active=True)
|
||||
def test_with_domain_renewal_flag_no_expiring_domains_w_org_feature_flag(self):
|
||||
def test_no_expiring_domains_w_org_feature_flag(self):
|
||||
UserDomainRole.objects.filter(user=self.user, domain=self.domain_with_expired_date).delete()
|
||||
UserDomainRole.objects.filter(user=self.user, domain=self.domain_with_expiring_soon_date).delete()
|
||||
self.client.force_login(self.user)
|
||||
|
|
|
@ -366,7 +366,7 @@ class DomainRenewalView(DomainBaseView):
|
|||
return HttpResponseRedirect(reverse("domain", kwargs={"pk": pk}))
|
||||
|
||||
# if not valid, render the template with error messages
|
||||
# passing editable, has_domain_renewal_flag, and is_editable for re-render
|
||||
# passing editable and is_editable for re-render
|
||||
return render(
|
||||
request,
|
||||
"domain_renewal.html",
|
||||
|
@ -374,7 +374,6 @@ class DomainRenewalView(DomainBaseView):
|
|||
"domain": domain,
|
||||
"form": form,
|
||||
"is_editable": True,
|
||||
"has_domain_renewal_flag": True,
|
||||
"is_domain_manager": True,
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue