mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 02:49:21 +02:00
Remove your contact information pointers and update tests
This commit is contained in:
parent
c909c2a094
commit
f3ae6f884c
5 changed files with 14 additions and 87 deletions
|
@ -386,64 +386,6 @@ class PurposeForm(RegistrarForm):
|
|||
)
|
||||
|
||||
|
||||
class YourContactForm(RegistrarForm):
|
||||
JOIN = "creator"
|
||||
|
||||
def to_database(self, obj):
|
||||
if not self.is_valid():
|
||||
return
|
||||
contact = getattr(obj, "creator", None)
|
||||
if contact is not None and not contact.has_more_than_one_join("submitted_domain_requests"):
|
||||
# if contact exists in the database and is not joined to other entities
|
||||
super().to_database(contact)
|
||||
else:
|
||||
# no contact exists OR contact exists which is joined also to other entities;
|
||||
# in either case, create a new contact and update it
|
||||
contact = Contact()
|
||||
super().to_database(contact)
|
||||
obj.creator = contact
|
||||
obj.save()
|
||||
|
||||
@classmethod
|
||||
def from_database(cls, obj):
|
||||
contact = getattr(obj, "creator", None)
|
||||
return super().from_database(contact)
|
||||
|
||||
first_name = forms.CharField(
|
||||
label="First name / given name",
|
||||
error_messages={"required": "Enter your first name / given name."},
|
||||
)
|
||||
middle_name = forms.CharField(
|
||||
required=False,
|
||||
label="Middle name (optional)",
|
||||
)
|
||||
last_name = forms.CharField(
|
||||
label="Last name / family name",
|
||||
error_messages={"required": "Enter your last name / family name."},
|
||||
)
|
||||
title = forms.CharField(
|
||||
label="Title or role in your organization",
|
||||
error_messages={
|
||||
"required": ("Enter your title or role in your organization (e.g., Chief Information Officer).")
|
||||
},
|
||||
)
|
||||
email = forms.EmailField(
|
||||
label="Email",
|
||||
max_length=None,
|
||||
error_messages={"invalid": ("Enter your email address in the required format, like name@example.com.")},
|
||||
validators=[
|
||||
MaxLengthValidator(
|
||||
320,
|
||||
message="Response must be less than 320 characters.",
|
||||
)
|
||||
],
|
||||
)
|
||||
phone = PhoneNumberField(
|
||||
label="Phone",
|
||||
error_messages={"invalid": "Enter a valid 10-digit phone number.", "required": "Enter your phone number."},
|
||||
)
|
||||
|
||||
|
||||
class OtherContactsYesNoForm(BaseYesNoForm):
|
||||
"""The yes/no field for the OtherContacts form."""
|
||||
|
||||
|
|
|
@ -72,13 +72,6 @@
|
|||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% if not has_profile_feature_flag %}
|
||||
{# Conditionally display profile link in main nav #}
|
||||
{% with url_name="domain-your-contact-information" %}
|
||||
{% include "includes/domain_sidenav_item.html" with item_text="Your contact information" %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
{% with url_name="domain-security-email" %}
|
||||
{% include "includes/domain_sidenav_item.html" with item_text="Security email" %}
|
||||
{% endwith %}
|
||||
|
|
|
@ -685,16 +685,14 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
already_has_domains = DomainRequest.ActionNeededReasons.ALREADY_HAS_DOMAINS
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=already_has_domains)
|
||||
|
||||
self.assert_email_is_accurate(
|
||||
"ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, _creator.email, bcc_email_address=BCC_EMAIL
|
||||
)
|
||||
self.assert_email_is_accurate("ORGANIZATION ALREADY HAS A .GOV DOMAIN", 0, EMAIL, bcc_email_address=BCC_EMAIL)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
|
||||
|
||||
# Test the email sent out for bad_name
|
||||
bad_name = DomainRequest.ActionNeededReasons.BAD_NAME
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=bad_name)
|
||||
self.assert_email_is_accurate(
|
||||
"DOMAIN NAME DOES NOT MEET .GOV REQUIREMENTS", 1, _creator.email, bcc_email_address=BCC_EMAIL
|
||||
"DOMAIN NAME DOES NOT MEET .GOV REQUIREMENTS", 1, EMAIL, bcc_email_address=BCC_EMAIL
|
||||
)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
|
||||
|
||||
|
@ -702,7 +700,7 @@ class TestDomainRequestAdmin(MockEppLib):
|
|||
eligibility_unclear = DomainRequest.ActionNeededReasons.ELIGIBILITY_UNCLEAR
|
||||
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=eligibility_unclear)
|
||||
self.assert_email_is_accurate(
|
||||
"ORGANIZATION MAY NOT MEET ELIGIBILITY REQUIREMENTS", 2, _creator.email, bcc_email_address=BCC_EMAIL
|
||||
"ORGANIZATION MAY NOT MEET ELIGIBILITY REQUIREMENTS", 2, EMAIL, bcc_email_address=BCC_EMAIL
|
||||
)
|
||||
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ from waffle.testutils import override_flag
|
|||
from registrar.utility import email
|
||||
from registrar.utility.email import send_templated_email
|
||||
from .common import completed_domain_request
|
||||
from registrar.models import AllowedEmail
|
||||
from registrar.models import AllowedEmail, User
|
||||
|
||||
from api.tests.common import less_console_noise_decorator
|
||||
from datetime import datetime
|
||||
|
@ -129,13 +129,21 @@ class TestEmails(TestCase):
|
|||
@less_console_noise_decorator
|
||||
def test_submission_confirmation_other_contacts_spacing(self):
|
||||
"""Test line spacing with other contacts."""
|
||||
domain_request = completed_domain_request(has_other_contacts=True)
|
||||
|
||||
# Create fake creator
|
||||
_creator = User.objects.create(
|
||||
username="MrMeoward", first_name="Meoward", last_name="Jones", phone="(888) 888 8888"
|
||||
)
|
||||
|
||||
# Create a fake domain request
|
||||
domain_request = completed_domain_request(has_other_contacts=True, user=_creator)
|
||||
with boto3_mocking.clients.handler_for("sesv2", self.mock_client_class):
|
||||
domain_request.submit()
|
||||
_, kwargs = self.mock_client.send_email.call_args
|
||||
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
|
||||
self.assertIn("Other employees from your organization:", body)
|
||||
# spacing should be right between adjacent elements self.assertRegex(body, r"5557\n\nAnything else")
|
||||
self.assertRegex(body, r"8888\n\nOther employees")
|
||||
self.assertRegex(body, r"5557\n\nAnything else")
|
||||
|
||||
@boto3_mocking.patching
|
||||
@less_console_noise_decorator
|
||||
|
|
|
@ -10,7 +10,6 @@ from registrar.forms.domain_request_wizard import (
|
|||
DotGovDomainForm,
|
||||
SeniorOfficialForm,
|
||||
OrganizationContactForm,
|
||||
YourContactForm,
|
||||
OtherContactsForm,
|
||||
RequirementsForm,
|
||||
TribalGovernmentForm,
|
||||
|
@ -366,19 +365,6 @@ class TestFormValidation(MockEppLib):
|
|||
["Response must be less than 2000 characters."],
|
||||
)
|
||||
|
||||
def test_your_contact_email_invalid(self):
|
||||
"""must be a valid email address."""
|
||||
form = YourContactForm(data={"email": "boss@boss"})
|
||||
self.assertEqual(
|
||||
form.errors["email"],
|
||||
["Enter your email address in the required format, like name@example.com."],
|
||||
)
|
||||
|
||||
def test_your_contact_phone_invalid(self):
|
||||
"""Must be a valid phone number."""
|
||||
form = YourContactForm(data={"phone": "boss@boss"})
|
||||
self.assertTrue(form.errors["phone"][0].startswith("Enter a valid 10-digit phone number."))
|
||||
|
||||
def test_other_contact_email_invalid(self):
|
||||
"""must be a valid email address."""
|
||||
form = OtherContactsForm(data={"email": "splendid@boss"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue