adding back some conditionals for feature flag

This commit is contained in:
asaki222 2024-09-10 10:27:28 -04:00
parent 8954efb537
commit db46ca9fe4
No known key found for this signature in database
GPG key ID: 2C4F802060E06EA4
4 changed files with 26 additions and 33 deletions

View file

@ -109,6 +109,9 @@
{% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level %} {% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level %}
{% endif %} {% endif %}
{% if DomainRequest.creator %}
{% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.creator contact='true' heading_level=heading_level %}
{% if DomainRequest.other_contacts.all %} {% if DomainRequest.other_contacts.all %}
{% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.other_contacts.all contact='true' list='true' heading_level=heading_level %} {% include "includes/summary_item.html" with title='Other employees from your organization' value=DomainRequest.other_contacts.all contact='true' list='true' heading_level=heading_level %}
{% else %} {% else %}

View file

@ -170,7 +170,6 @@ class TestDomainRequest(TestCase):
zipcode="12345-6789", zipcode="12345-6789",
senior_official=contact, senior_official=contact,
requested_domain=domain, requested_domain=domain,
submitter=contact,
purpose="Igorville rules!", purpose="Igorville rules!",
anything_else="All of Igorville loves the dotgov program.", anything_else="All of Igorville loves the dotgov program.",
is_policy_acknowledged=True, is_policy_acknowledged=True,
@ -197,7 +196,6 @@ class TestDomainRequest(TestCase):
state_territory="CA", state_territory="CA",
zipcode="12345-6789", zipcode="12345-6789",
senior_official=contact, senior_official=contact,
submitter=contact,
purpose="Igorville rules!", purpose="Igorville rules!",
anything_else="All of Igorville loves the dotgov program.", anything_else="All of Igorville loves the dotgov program.",
is_policy_acknowledged=True, is_policy_acknowledged=True,
@ -225,7 +223,7 @@ class TestDomainRequest(TestCase):
site = DraftDomain.objects.create(name="igorville.gov") site = DraftDomain.objects.create(name="igorville.gov")
domain_request = DomainRequest.objects.create(creator=user, requested_domain=site) domain_request = DomainRequest.objects.create(creator=user, requested_domain=site)
# no submitter email so this emits a log warning # no email sent to creator so this emits a log warning
with boto3_mocking.clients.handler_for("sesv2", self.mock_client): with boto3_mocking.clients.handler_for("sesv2", self.mock_client):
with less_console_noise(): with less_console_noise():
@ -258,19 +256,19 @@ class TestDomainRequest(TestCase):
email_allowed.delete() email_allowed.delete()
@override_flag("profile_feature", active=False)
@less_console_noise_decorator @less_console_noise_decorator
def test_submit_from_started_sends_email(self): def test_submit_from_started_sends_email(self):
msg = "Create a domain request and submit it and see if email was sent." msg = "Create a domain request and submit it and see if email was sent."
domain_request = completed_domain_request(submitter=self.dummy_user, user=self.dummy_user_2) domain_request = completed_domain_request(user=self.dummy_user_2)
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hello") self.check_email_sent(
domain_request, msg, "submit", 1, expected_content="Hi", expected_email=self.dummy_user_2.email
)
@override_flag("profile_feature", active=True)
@less_console_noise_decorator @less_console_noise_decorator
def test_submit_from_started_sends_email_to_creator(self): def test_submit_from_started_sends_email_to_creator(self):
"""Tests if, when the profile feature flag is on, we send an email to the creator""" """Tests if, when the profile feature flag is on, we send an email to the creator"""
msg = "Create a domain request and submit it and see if email was sent when the feature flag is on." msg = "Create a domain request and submit it and see if email was sent when the feature flag is on."
domain_request = completed_domain_request(submitter=self.dummy_user, user=self.dummy_user_2) domain_request = completed_domain_request(user=self.dummy_user_2)
self.check_email_sent( self.check_email_sent(
domain_request, msg, "submit", 1, expected_content="Lava", expected_email="intern@igorville.com" domain_request, msg, "submit", 1, expected_content="Lava", expected_email="intern@igorville.com"
) )
@ -278,10 +276,9 @@ class TestDomainRequest(TestCase):
@less_console_noise_decorator @less_console_noise_decorator
def test_submit_from_withdrawn_sends_email(self): def test_submit_from_withdrawn_sends_email(self):
msg = "Create a withdrawn domain request and submit it and see if email was sent." msg = "Create a withdrawn domain request and submit it and see if email was sent."
domain_request = completed_domain_request( user, _ = User.objects.get_or_create(username="testy")
status=DomainRequest.DomainRequestStatus.WITHDRAWN, submitter=self.dummy_user domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.WITHDRAWN, user=user)
) self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hi", expected_email=user.email)
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hello")
@less_console_noise_decorator @less_console_noise_decorator
def test_submit_from_action_needed_does_not_send_email(self): def test_submit_from_action_needed_does_not_send_email(self):
@ -298,26 +295,25 @@ class TestDomainRequest(TestCase):
@less_console_noise_decorator @less_console_noise_decorator
def test_approve_sends_email(self): def test_approve_sends_email(self):
msg = "Create a domain request and approve it and see if email was sent." msg = "Create a domain request and approve it and see if email was sent."
domain_request = completed_domain_request( user, _ = User.objects.get_or_create(username="testy")
status=DomainRequest.DomainRequestStatus.IN_REVIEW, submitter=self.dummy_user domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=user)
) self.check_email_sent(domain_request, msg, "approve", 1, expected_content="approved", expected_email=user.email)
self.check_email_sent(domain_request, msg, "approve", 1, expected_content="Hello")
@less_console_noise_decorator @less_console_noise_decorator
def test_withdraw_sends_email(self): def test_withdraw_sends_email(self):
msg = "Create a domain request and withdraw it and see if email was sent." msg = "Create a domain request and withdraw it and see if email was sent."
domain_request = completed_domain_request( user, _ = User.objects.get_or_create(username="testy")
status=DomainRequest.DomainRequestStatus.IN_REVIEW, submitter=self.dummy_user domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=user)
self.check_email_sent(
domain_request, msg, "withdraw", 1, expected_content="withdrawn", expected_email=user.email
) )
self.check_email_sent(domain_request, msg, "withdraw", 1, expected_content="Hello")
@less_console_noise_decorator @less_console_noise_decorator
def test_reject_sends_email(self): def test_reject_sends_email(self):
msg = "Create a domain request and reject it and see if email was sent." msg = "Create a domain request and reject it and see if email was sent."
domain_request = completed_domain_request( user, _ = User.objects.get_or_create(username="testy")
status=DomainRequest.DomainRequestStatus.APPROVED, submitter=self.dummy_user domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED, user=user)
) self.check_email_sent(domain_request, msg, "reject", 1, expected_content="rejected", expected_email=user.email)
self.check_email_sent(domain_request, msg, "reject", 1, expected_content="Hello")
@less_console_noise_decorator @less_console_noise_decorator
def test_reject_with_prejudice_does_not_send_email(self): def test_reject_with_prejudice_does_not_send_email(self):
@ -2069,7 +2065,6 @@ class TestDomainRequestIncomplete(TestCase):
senior_official=so, senior_official=so,
requested_domain=draft_domain, requested_domain=draft_domain,
purpose="Some purpose", purpose="Some purpose",
submitter=you,
no_other_contacts_rationale=None, no_other_contacts_rationale=None,
has_cisa_representative=True, has_cisa_representative=True,
cisa_representative_email="somerep@cisa.com", cisa_representative_email="somerep@cisa.com",
@ -2198,13 +2193,6 @@ class TestDomainRequestIncomplete(TestCase):
self.domain_request.save() self.domain_request.save()
self.assertFalse(self.domain_request._is_purpose_complete()) self.assertFalse(self.domain_request._is_purpose_complete())
@less_console_noise_decorator
def test_is_submitter_complete(self):
self.assertTrue(self.domain_request._is_submitter_complete())
self.domain_request.submitter = None
self.domain_request.save()
self.assertFalse(self.domain_request._is_submitter_complete())
@less_console_noise_decorator @less_console_noise_decorator
def test_is_other_contacts_complete_missing_one_field(self): def test_is_other_contacts_complete_missing_one_field(self):
self.assertTrue(self.domain_request._is_other_contacts_complete()) self.assertTrue(self.domain_request._is_other_contacts_complete())

View file

@ -59,7 +59,6 @@ from epplibwrapper import (
from ..utility.email import send_templated_email, EmailSendingError from ..utility.email import send_templated_email, EmailSendingError
from .utility import DomainPermissionView, DomainInvitationPermissionDeleteView from .utility import DomainPermissionView, DomainInvitationPermissionDeleteView
from waffle.decorators import waffle_flag
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -46,6 +46,9 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
return self.render_to_response(context) return self.render_to_response(context)
def dispatch(self, request, *args, **kwargs): # type: ignore
return super().dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
"""Extend get_context_data""" """Extend get_context_data"""
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)