Merge branch 'main' into za/2595-update-domain-request-view-only-pages

This commit is contained in:
zandercymatics 2024-09-19 11:15:04 -06:00
commit 999ed2f2e5
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
64 changed files with 2077 additions and 1884 deletions

View file

@ -6,7 +6,6 @@ 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
@ -340,13 +339,12 @@ class DomainRequest(TimeStampedModel):
help_text="The suborganization that this domain request is included under",
)
# This is the domain request user who created this domain request. The contact
# information that they gave is in the `submitter` field
# This is the domain request user who created this domain request.
creator = models.ForeignKey(
"registrar.User",
on_delete=models.PROTECT,
related_name="domain_requests_created",
help_text="Person who submitted the domain request; will not receive email updates",
help_text="Person who submitted the domain request. Will receive email updates.",
)
investigator = models.ForeignKey(
@ -425,7 +423,7 @@ class DomainRequest(TimeStampedModel):
choices=StateTerritoryChoices.choices,
null=True,
blank=True,
verbose_name="state / territory",
verbose_name="state, territory, or military post",
)
zipcode = models.CharField(
max_length=10,
@ -484,17 +482,6 @@ class DomainRequest(TimeStampedModel):
help_text="Other domain names the creator provided for consideration",
)
# This is the contact information provided by the domain requestor. The
# user who created the domain request is in the `creator` field.
submitter = models.ForeignKey(
"registrar.Contact",
null=True,
blank=True,
related_name="submitted_domain_requests",
on_delete=models.PROTECT,
help_text='Person listed under "your contact information" in the request form; will receive email updates',
)
purpose = models.TextField(
null=True,
blank=True,
@ -756,9 +743,6 @@ class DomainRequest(TimeStampedModel):
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
Optional args:
bcc_address: str -> the address to bcc to
@ -773,7 +757,7 @@ class DomainRequest(TimeStampedModel):
custom_email_content: str -> Renders an email with the content of this string as its body text.
"""
recipient = self.creator if flag_is_active(None, "profile_feature") else self.submitter
recipient = self.creator
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}."
@ -1202,6 +1186,10 @@ class DomainRequest(TimeStampedModel):
# Special District -> "Election office" and "About your organization" page can't be empty
return self.is_election_board is not None and self.about_your_organization is not None
# Do we still want to test this after creator is autogenerated? Currently it went back to being selectable
def _is_creator_complete(self):
return self.creator is not None
def _is_organization_name_and_address_complete(self):
return not (
self.organization_name is None
@ -1220,9 +1208,6 @@ class DomainRequest(TimeStampedModel):
def _is_purpose_complete(self):
return self.purpose is not None
def _is_submitter_complete(self):
return self.submitter is not None
def _has_other_contacts_and_filled(self):
# Other Contacts Radio button is Yes and if all required fields are filled
return (
@ -1271,14 +1256,12 @@ class DomainRequest(TimeStampedModel):
return self.is_policy_acknowledged is not None
def _is_general_form_complete(self, request):
has_profile_feature_flag = flag_is_active(request, "profile_feature")
return (
self._is_organization_name_and_address_complete()
self._is_creator_complete()
and self._is_organization_name_and_address_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 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()
and self._is_policy_acknowledgement_complete()