mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-17 18:09:25 +02:00
Merge branch 'main' into gd/2365-add-suborg-to-domain-info
This commit is contained in:
commit
882f66d497
56 changed files with 723 additions and 605 deletions
|
@ -7,6 +7,7 @@ from django.conf import settings
|
|||
from django.db import models
|
||||
from django_fsm import FSMField, transition # type: ignore
|
||||
from django.utils import timezone
|
||||
from waffle import flag_is_active
|
||||
from registrar.models.domain import Domain
|
||||
from registrar.models.federal_agency import FederalAgency
|
||||
from registrar.models.utility.generic_helper import CreateOrUpdateOrganizationTypeHelper
|
||||
|
@ -17,8 +18,6 @@ from .utility.time_stamped_model import TimeStampedModel
|
|||
from ..utility.email import send_templated_email, EmailSendingError
|
||||
from itertools import chain
|
||||
|
||||
from waffle.decorators import flag_is_active
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -267,7 +266,7 @@ class DomainRequest(TimeStampedModel):
|
|||
"""Defines common action needed reasons for domain requests"""
|
||||
|
||||
ELIGIBILITY_UNCLEAR = ("eligibility_unclear", "Unclear organization eligibility")
|
||||
QUESTIONABLE_AUTHORIZING_OFFICIAL = ("questionable_authorizing_official", "Questionable authorizing official")
|
||||
QUESTIONABLE_SENIOR_OFFICIAL = ("questionable_senior_official", "Questionable senior official")
|
||||
ALREADY_HAS_DOMAINS = ("already_has_domains", "Already has domains")
|
||||
BAD_NAME = ("bad_name", "Doesn’t meet naming requirements")
|
||||
OTHER = ("other", "Other (no auto-email sent)")
|
||||
|
@ -433,11 +432,11 @@ class DomainRequest(TimeStampedModel):
|
|||
blank=True,
|
||||
)
|
||||
|
||||
authorizing_official = models.ForeignKey(
|
||||
senior_official = models.ForeignKey(
|
||||
"registrar.Contact",
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name="authorizing_official",
|
||||
related_name="senior_official",
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
|
||||
|
@ -684,34 +683,50 @@ class DomainRequest(TimeStampedModel):
|
|||
def _send_status_update_email(
|
||||
self, new_status, email_template, email_template_subject, send_email=True, bcc_address="", wrap_email=False
|
||||
):
|
||||
"""Send a status update email to the submitter.
|
||||
"""Send a status update email to the creator.
|
||||
|
||||
The email goes to the email address that the submitter gave as their
|
||||
contact information. If there is not submitter information, then do
|
||||
The email goes to the email address that the creator gave as their
|
||||
contact information. If there is not creator information, then do
|
||||
nothing.
|
||||
|
||||
If the waffle flag "profile_feature" is active, then this email will be sent to the
|
||||
domain request creator rather than the submitter
|
||||
|
||||
send_email: bool -> Used to bypass the send_templated_email function, in the event
|
||||
we just want to log that an email would have been sent, rather than actually sending one.
|
||||
|
||||
wrap_email: bool -> Wraps emails using `wrap_text_and_preserve_paragraphs` if any given
|
||||
paragraph exceeds our desired max length (for prettier display).
|
||||
"""
|
||||
|
||||
if self.submitter is None or self.submitter.email is None:
|
||||
logger.warning(f"Cannot send {new_status} email, no submitter email address.")
|
||||
recipient = self.creator if flag_is_active(None, "profile_feature") else self.submitter
|
||||
if recipient is None or recipient.email is None:
|
||||
logger.warning(
|
||||
f"Cannot send {new_status} email, no creator email address for domain request with pk: {self.pk}."
|
||||
f" Name: {self.requested_domain.name}"
|
||||
if self.requested_domain
|
||||
else ""
|
||||
)
|
||||
return None
|
||||
|
||||
if not send_email:
|
||||
logger.info(f"Email was not sent. Would send {new_status} email: {self.submitter.email}")
|
||||
logger.info(f"Email was not sent. Would send {new_status} email to: {recipient.email}")
|
||||
return None
|
||||
|
||||
try:
|
||||
send_templated_email(
|
||||
email_template,
|
||||
email_template_subject,
|
||||
self.submitter.email,
|
||||
context={"domain_request": self},
|
||||
recipient.email,
|
||||
context={
|
||||
"domain_request": self,
|
||||
# This is the user that we refer to in the email
|
||||
"recipient": recipient,
|
||||
},
|
||||
bcc_address=bcc_address,
|
||||
wrap_email=wrap_email,
|
||||
)
|
||||
logger.info(f"The {new_status} email sent to: {self.submitter.email}")
|
||||
logger.info(f"The {new_status} email sent to: {recipient.email}")
|
||||
except EmailSendingError:
|
||||
logger.warning("Failed to send confirmation email", exc_info=True)
|
||||
|
||||
|
@ -1122,8 +1137,8 @@ class DomainRequest(TimeStampedModel):
|
|||
and self.zipcode is None
|
||||
)
|
||||
|
||||
def _is_authorizing_official_complete(self):
|
||||
return self.authorizing_official is not None
|
||||
def _is_senior_official_complete(self):
|
||||
return self.senior_official is not None
|
||||
|
||||
def _is_requested_domain_complete(self):
|
||||
return self.requested_domain is not None
|
||||
|
@ -1185,10 +1200,10 @@ class DomainRequest(TimeStampedModel):
|
|||
has_profile_feature_flag = flag_is_active(request, "profile_feature")
|
||||
return (
|
||||
self._is_organization_name_and_address_complete()
|
||||
and self._is_authorizing_official_complete()
|
||||
and self._is_senior_official_complete()
|
||||
and self._is_requested_domain_complete()
|
||||
and self._is_purpose_complete()
|
||||
# NOTE: This flag leaves submitter as empty (request wont submit) hence preset to True
|
||||
# NOTE: This flag leaves submitter as empty (request wont submit) hence set to True
|
||||
and (self._is_submitter_complete() if not has_profile_feature_flag else True)
|
||||
and self._is_other_contacts_complete()
|
||||
and self._is_additional_details_complete()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue