Merge pull request #2693 from cisagov/es/2162-delete-submitter-v2

[litterbox] 2162: Delete Submitter field and Your contact information page
This commit is contained in:
Rebecca H. 2024-09-13 08:35:59 -07:00 committed by GitHub
commit c1daa455ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 448 additions and 791 deletions

View file

@ -42,7 +42,6 @@ class DomainRequest {
creator (User)
investigator (User)
senior_official (Contact)
submitter (Contact)
other_contacts (Contacts)
approved_domain (Domain)
requested_domain (DraftDomain)
@ -80,7 +79,7 @@ class Contact {
--
}
DomainRequest *-r-* Contact : senior_official, submitter, other_contacts
DomainRequest *-r-* Contact : senior_official, other_contacts
class DraftDomain {
Requested domain

View file

@ -38,7 +38,6 @@ class "registrar.Contact <Registrar>" as registrar.Contact #d6f4e9 {
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
~ user (OneToOneField)
+ first_name (CharField)
+ middle_name (CharField)
+ last_name (CharField)
@ -47,7 +46,6 @@ class "registrar.Contact <Registrar>" as registrar.Contact #d6f4e9 {
+ phone (PhoneNumberField)
--
}
registrar.Contact -- registrar.User
class "registrar.Host <Registrar>" as registrar.Host #d6f4e9 {
@ -143,6 +141,8 @@ class "registrar.FederalAgency <Registrar>" as registrar.FederalAgency #d6f4e9 {
+ updated_at (DateTimeField)
+ agency (CharField)
+ federal_type (CharField)
+ initials (CharField)
+ is_fceb (BooleanField)
--
}
@ -159,6 +159,7 @@ class "registrar.DomainRequest <Registrar>" as registrar.DomainRequest #d6f4e9 {
+ action_needed_reason_email (TextField)
~ federal_agency (ForeignKey)
~ portfolio (ForeignKey)
~ sub_organization (ForeignKey)
~ creator (ForeignKey)
~ investigator (ForeignKey)
+ generic_org_type (CharField)
@ -179,7 +180,6 @@ class "registrar.DomainRequest <Registrar>" as registrar.DomainRequest #d6f4e9 {
~ senior_official (ForeignKey)
~ approved_domain (OneToOneField)
~ requested_domain (OneToOneField)
~ submitter (ForeignKey)
+ purpose (TextField)
+ no_other_contacts_rationale (TextField)
+ anything_else (TextField)
@ -198,12 +198,12 @@ class "registrar.DomainRequest <Registrar>" as registrar.DomainRequest #d6f4e9 {
}
registrar.DomainRequest -- registrar.FederalAgency
registrar.DomainRequest -- registrar.Portfolio
registrar.DomainRequest -- registrar.Suborganization
registrar.DomainRequest -- registrar.User
registrar.DomainRequest -- registrar.User
registrar.DomainRequest -- registrar.Contact
registrar.DomainRequest -- registrar.Domain
registrar.DomainRequest -- registrar.DraftDomain
registrar.DomainRequest -- registrar.Contact
registrar.DomainRequest *--* registrar.Website
registrar.DomainRequest *--* registrar.Website
registrar.DomainRequest *--* registrar.Contact
@ -218,6 +218,7 @@ class "registrar.DomainInformation <Registrar>" as registrar.DomainInformation #
~ federal_agency (ForeignKey)
~ creator (ForeignKey)
~ portfolio (ForeignKey)
~ sub_organization (ForeignKey)
~ domain_request (OneToOneField)
+ generic_org_type (CharField)
+ organization_type (CharField)
@ -236,7 +237,6 @@ class "registrar.DomainInformation <Registrar>" as registrar.DomainInformation #
+ about_your_organization (TextField)
~ senior_official (ForeignKey)
~ domain (OneToOneField)
~ submitter (ForeignKey)
+ purpose (TextField)
+ no_other_contacts_rationale (TextField)
+ anything_else (TextField)
@ -253,10 +253,10 @@ class "registrar.DomainInformation <Registrar>" as registrar.DomainInformation #
registrar.DomainInformation -- registrar.FederalAgency
registrar.DomainInformation -- registrar.User
registrar.DomainInformation -- registrar.Portfolio
registrar.DomainInformation -- registrar.Suborganization
registrar.DomainInformation -- registrar.DomainRequest
registrar.DomainInformation -- registrar.Contact
registrar.DomainInformation -- registrar.Domain
registrar.DomainInformation -- registrar.Contact
registrar.DomainInformation *--* registrar.Contact
@ -285,6 +285,38 @@ class "registrar.DomainInvitation <Registrar>" as registrar.DomainInvitation #d6
registrar.DomainInvitation -- registrar.Domain
class "registrar.UserPortfolioPermission <Registrar>" as registrar.UserPortfolioPermission #d6f4e9 {
user portfolio permission
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
~ user (ForeignKey)
~ portfolio (ForeignKey)
+ roles (ArrayField)
+ additional_permissions (ArrayField)
--
}
registrar.UserPortfolioPermission -- registrar.User
registrar.UserPortfolioPermission -- registrar.Portfolio
class "registrar.PortfolioInvitation <Registrar>" as registrar.PortfolioInvitation #d6f4e9 {
portfolio invitation
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ email (EmailField)
~ portfolio (ForeignKey)
+ portfolio_roles (ArrayField)
+ portfolio_additional_permissions (ArrayField)
+ status (FSMField)
--
}
registrar.PortfolioInvitation -- registrar.Portfolio
class "registrar.TransitionDomain <Registrar>" as registrar.TransitionDomain #d6f4e9 {
transition domain
--
@ -409,10 +441,11 @@ class "registrar.Portfolio <Registrar>" as registrar.Portfolio #d6f4e9 {
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
~ creator (ForeignKey)
+ organization_name (CharField)
+ organization_type (CharField)
+ notes (TextField)
~ federal_agency (ForeignKey)
+ organization_type (CharField)
+ organization_name (CharField)
~ senior_official (ForeignKey)
+ address_line1 (CharField)
+ address_line2 (CharField)
+ city (CharField)
@ -424,6 +457,7 @@ class "registrar.Portfolio <Registrar>" as registrar.Portfolio #d6f4e9 {
}
registrar.Portfolio -- registrar.User
registrar.Portfolio -- registrar.FederalAgency
registrar.Portfolio -- registrar.SeniorOfficial
class "registrar.DomainGroup <Registrar>" as registrar.DomainGroup #d6f4e9 {
@ -454,7 +488,21 @@ class "registrar.Suborganization <Registrar>" as registrar.Suborganization #d6f4
registrar.Suborganization -- registrar.Portfolio
@enduml
```
class "registrar.SeniorOfficial <Registrar>" as registrar.SeniorOfficial #d6f4e9 {
senior official
--
+ id (BigAutoField)
+ created_at (DateTimeField)
+ updated_at (DateTimeField)
+ first_name (CharField)
+ last_name (CharField)
+ title (CharField)
+ phone (PhoneNumberField)
+ email (EmailField)
~ federal_agency (ForeignKey)
--
}
registrar.SeniorOfficial -- registrar.FederalAgency
</details>
@enduml

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 116 KiB

After

Width:  |  Height:  |  Size: 130 KiB

Before After
Before After

View file

@ -14,7 +14,7 @@
- Starting Location: Home page
- Workflow: (Domain requests Table) Manage domain
- Workflow Step: Click "Manage" -> Click "Withdraw request" -> (confirmation prompt) -> Click "Withdraw request" (inside prompt)
- Notes: You can also do this through Django Admin by switching a domain of status "submitted" to "withdrawn", but you need to be the submitter (email listed on Your Contact Information).
- Notes: You can also do this through Django Admin by switching a domain of status "submitted" to "withdrawn", but you need to be the creator.
- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/domain_request_withdrawn.txt)
### Domain Request Withdrawn Subject
@ -25,7 +25,7 @@
- Starting Location: Django Admin
- Workflow: Analyst Admin
- Workflow Step: Click "domain requests" -> Click a domain request in a status of "submitted", "In review", "rejected", or "ineligible" -> Click status dropdown -> (select "approved") -> click "Save"
- Notes: Note that this will send an email to the submitter (email listed on Your Contact Information). To test this with your own email, you need to create a domain request, then set the status to "approved". This will send you an email.
- Notes: Note that this will send an email to the creator. To test this with your own email, you need to create a domain request, then set the status to "approved". This will send you an email.
- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/status_change_approved.txt)
### Status Change Approved Subject
@ -36,7 +36,7 @@
- Starting Location: Django Admin
- Workflow: Analyst Admin
- Workflow Step: Click "domain requests" -> Click a domain request in a status of "In review", or "approved" -> Click status dropdown -> (select "rejected") -> click "Save"
- Notes: Note that this will send an email to the submitter (email listed on Your Contact Information). To test this with your own email, you need to create a domain request, then set the status to "in review" (and click save). Then, go back to the same application and set the status to "rejected". This will send you an email.
- Notes: Note that this will send an email to the creator. To test this with your own email, you need to create a domain request, then set the status to "in review" (and click save). Then, go back to the same application and set the status to "rejected". This will send you an email.
- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/status_change_rejected.txt)
### Status Change Rejected Subject
@ -47,7 +47,7 @@
- Starting Location: Home Page
- Workflow: Start domain request
- Workflow Step: Click "Start a new domain request" -> (fill out the form) -> On the last step ("Review and submit your domain request "), click "Submit your domain request"
- Notes: Note that this will send an email to the submitter (email listed on Your Contact Information)
- Notes: Note that this will send an email to the creator.
- [Email Content](https://github.com/cisagov/manage.get.gov/blob/main/src/registrar/templates/emails/submission_confirmation.txt)
### Submission Confirmation Subject

View file

@ -536,7 +536,6 @@ class AdminSortFields:
sort_mapping = {
# == Contact == #
"other_contacts": (Contact, _name_sort),
"submitter": (Contact, _name_sort),
# == Senior Official == #
"senior_official": (SeniorOfficial, _name_sort),
# == User == #
@ -1443,13 +1442,9 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"domain",
"generic_org_type",
"created_at",
"submitter",
]
orderable_fk_fields = [
("domain", "name"),
("submitter", ["first_name", "last_name"]),
]
orderable_fk_fields = [("domain", "name")]
# Filters
list_filter = ["generic_org_type"]
@ -1461,7 +1456,7 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
search_help_text = "Search by domain."
fieldsets = [
(None, {"fields": ["portfolio", "sub_organization", "creator", "submitter", "domain_request", "notes"]}),
(None, {"fields": ["portfolio", "sub_organization", "creator", "domain_request", "notes"]}),
(".gov domain", {"fields": ["domain"]}),
("Contacts", {"fields": ["senior_official", "other_contacts", "no_other_contacts_rationale"]}),
("Background info", {"fields": ["anything_else"]}),
@ -1525,7 +1520,6 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"more_organization_information",
"domain",
"domain_request",
"submitter",
"no_other_contacts_rationale",
"anything_else",
"is_policy_acknowledged",
@ -1540,7 +1534,6 @@ class DomainInformationAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"domain_request",
"senior_official",
"domain",
"submitter",
"portfolio",
"sub_organization",
]
@ -1713,13 +1706,11 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"custom_election_board",
"city",
"state_territory",
"submitter",
"investigator",
]
orderable_fk_fields = [
("requested_domain", "name"),
("submitter", ["first_name", "last_name"]),
("investigator", ["first_name", "last_name"]),
]
@ -1749,11 +1740,11 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
# Search
search_fields = [
"requested_domain__name",
"submitter__email",
"submitter__first_name",
"submitter__last_name",
"creator__email",
"creator__first_name",
"creator__last_name",
]
search_help_text = "Search by domain or submitter."
search_help_text = "Search by domain or creator."
fieldsets = [
(
@ -1769,7 +1760,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"action_needed_reason_email",
"investigator",
"creator",
"submitter",
"approved_domain",
"notes",
]
@ -1857,7 +1847,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"approved_domain",
"alternative_domains",
"purpose",
"submitter",
"no_other_contacts_rationale",
"anything_else",
"is_policy_acknowledged",
@ -1868,7 +1857,6 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
autocomplete_fields = [
"approved_domain",
"requested_domain",
"submitter",
"creator",
"senior_official",
"investigator",
@ -1990,12 +1978,8 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
"""
# TODO 2574: remove lines 1977-1978 (refactor as needed)
profile_flag = flag_is_active(request, "profile_feature")
if profile_flag and hasattr(obj, "creator"):
if hasattr(obj, "creator"):
recipient = obj.creator
elif not profile_flag and hasattr(obj, "submitter"):
recipient = obj.submitter
else:
recipient = None
@ -2231,10 +2215,7 @@ class DomainRequestAdmin(ListHeaderAdmin, ImportExportModelAdmin):
if not action_needed_reason or action_needed_reason == DomainRequest.ActionNeededReasons.OTHER:
return None
if flag_is_active(None, "profile_feature"): # type: ignore
recipient = domain_request.creator
else:
recipient = domain_request.submitter
recipient = domain_request.creator
# Return the context of the rendered views
context = {"domain_request": domain_request, "recipient": recipient}

View file

@ -53,7 +53,6 @@ for step, view in [
(Step.CURRENT_SITES, views.CurrentSites),
(Step.DOTGOV_DOMAIN, views.DotgovDomain),
(Step.PURPOSE, views.Purpose),
(Step.YOUR_CONTACT, views.YourContact),
(Step.OTHER_CONTACTS, views.OtherContacts),
(Step.ADDITIONAL_DETAILS, views.AdditionalDetails),
(Step.REQUIREMENTS, views.Requirements),
@ -213,11 +212,6 @@ urlpatterns = [
views.DomainDsDataView.as_view(),
name="domain-dns-dnssec-dsdata",
),
path(
"domain/<int:pk>/your-contact-information",
views.DomainYourContactInformationView.as_view(),
name="domain-your-contact-information",
),
path(
"domain/<int:pk>/org-name-address",
views.DomainOrgNameAddressView.as_view(),

View file

@ -37,7 +37,6 @@ class DomainRequestFixture:
# "anything_else": None,
# "is_policy_acknowledged": None,
# "senior_official": None,
# "submitter": None,
# "other_contacts": [],
# "current_websites": [],
# "alternative_domains": [],
@ -123,12 +122,6 @@ class DomainRequestFixture:
else:
da.senior_official = Contact.objects.create(**cls.fake_contact())
if not da.submitter:
if "submitter" in app and app["submitter"] is not None:
da.submitter, _ = Contact.objects.get_or_create(**app["submitter"])
else:
da.submitter = Contact.objects.create(**cls.fake_contact())
if not da.requested_domain:
if "requested_domain" in app and app["requested_domain"] is not None:
da.requested_domain, _ = DraftDomain.objects.get_or_create(name=app["requested_domain"])

View file

@ -386,64 +386,6 @@ class PurposeForm(RegistrarForm):
)
class YourContactForm(RegistrarForm):
JOIN = "submitter"
def to_database(self, obj):
if not self.is_valid():
return
contact = getattr(obj, "submitter", 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.submitter = contact
obj.save()
@classmethod
def from_database(cls, obj):
contact = getattr(obj, "submitter", 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."""

View file

@ -0,0 +1,38 @@
# Generated by Django 4.2.10 on 2024-08-29 23:17
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("registrar", "0124_alter_portfolioinvitation_portfolio_additional_permissions_and_more"),
]
operations = [
migrations.AlterField(
model_name="domaininformation",
name="submitter",
field=models.ForeignKey(
blank=True,
help_text='Person listed under "your contact information" in the request form',
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="submitted_domain_requests_information",
to="registrar.contact",
),
),
migrations.AlterField(
model_name="domainrequest",
name="submitter",
field=models.ForeignKey(
blank=True,
help_text='Person listed under "your contact information" in the request form; will receive email updates',
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="submitted_domain_requests",
to="registrar.contact",
),
),
]

View file

@ -0,0 +1,27 @@
from django.db import migrations
from django.db.models import Q
from typing import Any
# Deletes Contact objects associated with a submitter which we are deprecating
def cascade_delete_submitter_contacts(apps, schema_editor) -> Any:
contacts_model = apps.get_model("registrar", "Contact")
submitter_contacts = contacts_model.objects.filter(
Q(submitted_domain_requests__isnull=False) | Q(submitted_domain_requests_information__isnull=False)
).filter(
information_senior_official__isnull=True,
senior_official__isnull=True,
contact_domain_requests_information__isnull=True,
contact_domain_requests__isnull=True,
)
submitter_contacts.delete()
class Migration(migrations.Migration):
dependencies = [
("registrar", "0125_alter_domaininformation_submitter_and_more"),
]
operations = [
migrations.RunPython(cascade_delete_submitter_contacts, reverse_code=migrations.RunPython.noop, atomic=True),
]

View file

@ -0,0 +1,33 @@
# Generated by Django 4.2.10 on 2024-08-29 24:13
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
("registrar", "0126_delete_cascade_submitter_contacts"),
]
operations = [
migrations.RemoveField(
model_name="domaininformation",
name="submitter",
),
migrations.RemoveField(
model_name="domainrequest",
name="submitter",
),
migrations.AlterField(
model_name="domainrequest",
name="creator",
field=models.ForeignKey(
help_text="Person who submitted the domain request. Will receive email updates.",
on_delete=django.db.models.deletion.PROTECT,
related_name="domain_requests_created",
to=settings.AUTH_USER_MODEL,
),
),
]

View file

@ -48,8 +48,7 @@ class DomainInformation(TimeStampedModel):
null=True,
)
# 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,
@ -197,17 +196,6 @@ class DomainInformation(TimeStampedModel):
related_name="domain_info",
)
# 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_information",
on_delete=models.PROTECT,
help_text='Person listed under "your contact information" in the request form',
)
purpose = models.TextField(
null=True,
blank=True,

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
@ -339,13 +338,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(
@ -483,17 +481,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,
@ -741,9 +728,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
@ -758,7 +742,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}."
@ -1182,6 +1166,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
@ -1200,9 +1188,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 (
@ -1251,14 +1236,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()

View file

@ -70,7 +70,7 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
<div class="readonly textarea-wrapper">
<div id="action_needed_reason_email_readonly" class="dja-readonly-textarea-container padding-1 margin-top-0 padding-top-0 margin-bottom-1 thin-border collapse--dgsimple collapsed">
<label class="max-full" for="action_needed_reason_email_view_more">
<strong>Sent to {% if has_profile_feature_flag %}creator{%else%}submitter{%endif%}</strong>
<strong>Sent to creator</strong>
</label>
<textarea id="action_needed_reason_email_view_more" cols="40" rows="20" class="{% if not original_object.action_needed_reason %}display-none{% endif %}" readonly>
{{ original_object.action_needed_reason_email }}
@ -287,11 +287,6 @@ This is using a custom implementation fieldset.html (see admin/fieldset.html)
{% if not skip_additional_contact_info %}
{% include "django/admin/includes/user_detail_list.html" with user=original_object.creator no_title_top_padding=field.is_readonly %}
{% endif%}
{% elif field.field.name == "submitter" %}
<div class="flex-container tablet:margin-top-2">
<label aria-label="Submitter contact details"></label>
{% include "django/admin/includes/contact_detail_list.html" with user=original_object.submitter no_title_top_padding=field.is_readonly %}
</div>
{% elif field.field.name == "senior_official" %}
<div class="flex-container">
<label aria-label="Senior official contact details"></label>

View file

@ -130,8 +130,8 @@
{% if step == Step.YOUR_CONTACT %}
{% namespaced_url 'domain-request' step as domain_request_url %}
{% if domain_request.submitter is not None %}
{% with title=form_titles|get_item:step value=domain_request.submitter %}
{% if domain_request.creator is not None %}
{% with title=form_titles|get_item:step value=domain_request.creator %}
{% include "includes/summary_item.html" with title=title value=value heading_level=heading_level editable=True edit_link=domain_request_url contact='true' %}
{% endwith %}
{% else %}

View file

@ -127,8 +127,8 @@
{% include "includes/summary_item.html" with title='Purpose of your domain' value=DomainRequest.purpose heading_level=heading_level %}
{% endif %}
{% if DomainRequest.submitter and not has_profile_feature_flag %}
{% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.submitter contact='true' heading_level=heading_level %}
{% if DomainRequest.creator %}
{% include "includes/summary_item.html" with title='Your contact information' value=DomainRequest.creator contact='true' heading_level=heading_level %}
{% endif %}
{% if DomainRequest.other_contacts.all %}

View file

@ -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 %}

View file

@ -1,37 +0,0 @@
{% extends "domain_base.html" %}
{% load static field_helpers %}
{% block title %}Your contact information | {{ domain.name }} | {% endblock %}
{% block domain_content %}
{% include "includes/form_errors.html" with form=form %}
<h1>Your contact information</h1>
<p>If youd like us to use a different name, email, or phone number you can make those changes below. <strong>Updating your contact information here will update the contact information for all domains in your account.</strong> Changing your information here wont affect your Login.gov account information. The contact information you provide here wont be made public and will only be used for the .gov program.
</p>
{% include "includes/required_fields.html" %}
<form class="usa-form usa-form--large" method="post" novalidate id="form-container">
{% csrf_token %}
{% input_with_errors form.first_name %}
{% input_with_errors form.middle_name %}
{% input_with_errors form.last_name %}
{% input_with_errors form.title %}
{% input_with_errors form.email %}
{% input_with_errors form.phone %}
<button
type="submit"
class="usa-button"
>Save</button>
</form>
{% endblock %} {# domain_content #}

View file

@ -394,7 +394,6 @@ class AuditedAdminMockData:
about_your_organization: str = "e-Government",
anything_else: str = "There is more",
senior_official: Contact = self.dummy_contact(item_name, "senior_official"),
submitter: Contact = self.dummy_contact(item_name, "submitter"),
creator: User = self.dummy_user(item_name, "creator"),
}
""" # noqa
@ -412,7 +411,6 @@ class AuditedAdminMockData:
about_your_organization="e-Government",
anything_else="There is more",
senior_official=self.dummy_contact(item_name, "senior_official"),
submitter=self.dummy_contact(item_name, "submitter"),
creator=creator,
)
return common_args
@ -901,7 +899,6 @@ def completed_domain_request( # noqa
has_cisa_representative=True,
status=DomainRequest.DomainRequestStatus.STARTED,
user=False,
submitter=False,
name="city.gov",
investigator=None,
generic_org_type="federal",
@ -926,14 +923,6 @@ def completed_domain_request( # noqa
domain, _ = DraftDomain.objects.get_or_create(name=name)
alt, _ = Website.objects.get_or_create(website="city1.gov")
current, _ = Website.objects.get_or_create(website="city.com")
if not submitter:
submitter, _ = Contact.objects.get_or_create(
first_name="Testy2",
last_name="Tester2",
title="Admin Tester",
email="mayor@igorville.gov",
phone="(555) 555 5556",
)
other, _ = Contact.objects.get_or_create(
first_name="Testy",
last_name="Tester",
@ -962,7 +951,6 @@ def completed_domain_request( # noqa
zipcode="10002",
senior_official=so,
requested_domain=domain,
submitter=submitter,
creator=user,
status=status,
investigator=investigator,

View file

@ -63,6 +63,7 @@ from .common import (
from registrar.models.utility.portfolio_helper import UserPortfolioPermissionChoices, UserPortfolioRoleChoices
from django.contrib.sessions.backends.db import SessionStore
from django.contrib.auth import get_user_model
from unittest.mock import ANY, patch, Mock
@ -384,7 +385,7 @@ class TestDomainInformationAdmin(TestCase):
contact, _ = Contact.objects.get_or_create(first_name="Henry", last_name="McFakerson")
domain_request = completed_domain_request(
submitter=contact, name="city1244.gov", status=DomainRequest.DomainRequestStatus.IN_REVIEW
name="city1244.gov", status=DomainRequest.DomainRequestStatus.IN_REVIEW
)
domain_request.approve()
@ -509,7 +510,6 @@ class TestDomainInformationAdmin(TestCase):
# These should exist in the response
expected_values = [
("creator", "Person who submitted the domain request"),
("submitter", 'Person listed under "your contact information" in the request form'),
("domain_request", "Request associated with this domain"),
("no_other_contacts_rationale", "Required if creator does not list other employees"),
("urbanization", "Required for Puerto Rico only"),
@ -633,16 +633,6 @@ class TestDomainInformationAdmin(TestCase):
# Check for the field itself
self.assertContains(response, "Meoward Jones")
# == Check for the submitter == #
self.assertContains(response, "mayor@igorville.gov", count=2)
expected_submitter_fields = [
# Field, expected value
("title", "Admin Tester"),
("phone", "(555) 555 5556"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields)
self.assertContains(response, "Testy2 Tester2")
# == Check for the senior_official == #
self.assertContains(response, "testy@town.com", count=2)
expected_so_fields = [
@ -664,7 +654,7 @@ class TestDomainInformationAdmin(TestCase):
self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields)
# Test for the copy link
self.assertContains(response, "button--clipboard", count=4)
self.assertContains(response, "button--clipboard", count=3)
# cleanup this test
domain_info.delete()
@ -688,7 +678,6 @@ class TestDomainInformationAdmin(TestCase):
"more_organization_information",
"domain",
"domain_request",
"submitter",
"no_other_contacts_rationale",
"anything_else",
"is_policy_acknowledged",
@ -707,19 +696,19 @@ class TestDomainInformationAdmin(TestCase):
# Assert that sorting in reverse works correctly
self.test_helper.assert_table_sorted("-1", ("-domain__name",))
def test_submitter_sortable(self):
"""Tests if DomainInformation sorts by submitter correctly"""
def test_creator_sortable(self):
"""Tests if DomainInformation sorts by creator correctly"""
with less_console_noise():
self.client.force_login(self.superuser)
# Assert that our sort works correctly
self.test_helper.assert_table_sorted(
"4",
("submitter__first_name", "submitter__last_name"),
("creator__first_name", "creator__last_name"),
)
# Assert that sorting in reverse works correctly
self.test_helper.assert_table_sorted("-4", ("-submitter__first_name", "-submitter__last_name"))
self.test_helper.assert_table_sorted("-4", ("-creator__first_name", "-creator__last_name"))
class TestUserDomainRoleAdmin(TestCase):
@ -1317,7 +1306,6 @@ class AuditedAdminTest(TestCase):
# Senior offical is commented out for now - this is alphabetized
# and this test does not accurately reflect that.
# DomainRequest.senior_official.field,
DomainRequest.submitter.field,
# DomainRequest.investigator.field,
DomainRequest.creator.field,
DomainRequest.requested_domain.field,
@ -1377,7 +1365,6 @@ class AuditedAdminTest(TestCase):
# Senior offical is commented out for now - this is alphabetized
# and this test does not accurately reflect that.
# DomainInformation.senior_official.field,
DomainInformation.submitter.field,
# DomainInformation.creator.field,
(DomainInformation.domain.field, ["name"]),
(DomainInformation.domain_request.field, ["requested_domain__name"]),
@ -1686,91 +1673,6 @@ class TestContactAdmin(TestCase):
self.assertEqual(readonly_fields, expected_fields)
def test_change_view_for_joined_contact_five_or_less(self):
"""Create a contact, join it to 4 domain requests.
Assert that the warning on the contact form lists 4 joins."""
with less_console_noise():
self.client.force_login(self.superuser)
# Create an instance of the model
contact, _ = Contact.objects.get_or_create(
first_name="Henry",
last_name="McFakerson",
)
# join it to 4 domain requests.
domain_request1 = completed_domain_request(submitter=contact, name="city1.gov")
domain_request2 = completed_domain_request(submitter=contact, name="city2.gov")
domain_request3 = completed_domain_request(submitter=contact, name="city3.gov")
domain_request4 = completed_domain_request(submitter=contact, name="city4.gov")
with patch("django.contrib.messages.warning") as mock_warning:
# Use the test client to simulate the request
response = self.client.get(reverse("admin:registrar_contact_change", args=[contact.pk]))
# Assert that the error message was called with the correct argument
# Note: The 5th join will be a user.
mock_warning.assert_called_once_with(
response.wsgi_request,
"<ul class='messagelist_content-list--unstyled'>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request1.pk}/change/'>city1.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request2.pk}/change/'>city2.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request3.pk}/change/'>city3.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request4.pk}/change/'>city4.gov</a></li>"
"</ul>",
)
# cleanup this test
DomainRequest.objects.all().delete()
contact.delete()
def test_change_view_for_joined_contact_five_or_more(self):
"""Create a contact, join it to 6 domain requests.
Assert that the warning on the contact form lists 5 joins and a '1 more' ellispsis."""
with less_console_noise():
self.client.force_login(self.superuser)
# Create an instance of the model
# join it to 6 domain requests.
contact, _ = Contact.objects.get_or_create(
first_name="Henry",
last_name="McFakerson",
)
domain_request1 = completed_domain_request(submitter=contact, name="city1.gov")
domain_request2 = completed_domain_request(submitter=contact, name="city2.gov")
domain_request3 = completed_domain_request(submitter=contact, name="city3.gov")
domain_request4 = completed_domain_request(submitter=contact, name="city4.gov")
domain_request5 = completed_domain_request(submitter=contact, name="city5.gov")
completed_domain_request(submitter=contact, name="city6.gov")
with patch("django.contrib.messages.warning") as mock_warning:
# Use the test client to simulate the request
response = self.client.get(reverse("admin:registrar_contact_change", args=[contact.pk]))
logger.debug(mock_warning)
# Assert that the error message was called with the correct argument
# Note: The 6th join will be a user.
mock_warning.assert_called_once_with(
response.wsgi_request,
"<ul class='messagelist_content-list--unstyled'>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request1.pk}/change/'>city1.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request2.pk}/change/'>city2.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request3.pk}/change/'>city3.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request4.pk}/change/'>city4.gov</a></li>"
"<li>Joined to DomainRequest: <a href='/admin/registrar/"
f"domainrequest/{domain_request5.pk}/change/'>city5.gov</a></li>"
"</ul>"
"<p class='font-sans-3xs'>And 1 more...</p>",
)
# cleanup this test
DomainRequest.objects.all().delete()
contact.delete()
class TestVerifiedByStaffAdmin(TestCase):

View file

@ -427,13 +427,6 @@ class TestDomainAdminWithClient(TestCase):
# Check for the field itself
self.assertContains(response, "Meoward Jones")
# == Check for the submitter == #
self.assertContains(response, "mayor@igorville.gov")
self.assertContains(response, "Admin Tester")
self.assertContains(response, "(555) 555 5556")
self.assertContains(response, "Testy2 Tester2")
# == Check for the senior_official == #
self.assertContains(response, "testy@town.com")
self.assertContains(response, "Chief Tester")

View file

@ -37,6 +37,7 @@ from .common import (
GenericTestHelper,
)
from unittest.mock import patch
from waffle.testutils import override_flag
from django.conf import settings
import boto3_mocking # type: ignore
@ -100,7 +101,7 @@ class TestDomainRequestAdmin(MockEppLib):
SeniorOfficial.objects.get_or_create(first_name="Zoup", last_name="Soup", title="title")
contact, _ = Contact.objects.get_or_create(first_name="Henry", last_name="McFakerson")
domain_request = completed_domain_request(submitter=contact, name="city1.gov")
domain_request = completed_domain_request(name="city1.gov")
request = self.factory.post("/admin/registrar/domainrequest/{}/change/".format(domain_request.pk))
model_admin = AuditedAdmin(DomainRequest, self.site)
@ -155,11 +156,7 @@ class TestDomainRequestAdmin(MockEppLib):
# These should exist in the response
expected_values = [
("creator", "Person who submitted the domain request; will not receive email updates"),
(
"submitter",
'Person listed under "your contact information" in the request form; will receive email updates',
),
("creator", "Person who submitted the domain request. Will receive email updates"),
("approved_domain", "Domain associated with this request; will be blank until request is approved"),
("no_other_contacts_rationale", "Required if creator does not list other employees"),
("alternative_domains", "Other domain names the creator provided for consideration"),
@ -442,8 +439,8 @@ class TestDomainRequestAdmin(MockEppLib):
self.test_helper.assert_table_sorted("-1", ("-requested_domain__name",))
@less_console_noise_decorator
def test_submitter_sortable(self):
"""Tests if the DomainRequest sorts by submitter correctly"""
def test_creator_sortable(self):
"""Tests if the DomainRequest sorts by creator correctly"""
self.client.force_login(self.superuser)
multiple_unalphabetical_domain_objects("domain_request")
@ -457,8 +454,8 @@ class TestDomainRequestAdmin(MockEppLib):
self.test_helper.assert_table_sorted(
"13",
(
"submitter__first_name",
"submitter__last_name",
"creator__first_name",
"creator__last_name",
),
)
@ -466,8 +463,8 @@ class TestDomainRequestAdmin(MockEppLib):
self.test_helper.assert_table_sorted(
"-13",
(
"-submitter__first_name",
"-submitter__last_name",
"-creator__first_name",
"-creator__last_name",
),
)
@ -665,15 +662,24 @@ class TestDomainRequestAdmin(MockEppLib):
def test_action_needed_sends_reason_email_prod_bcc(self):
"""When an action needed reason is set, an email is sent out and help@get.gov
is BCC'd in production"""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
# Create fake creator
EMAIL = "meoward.jones@igorville.gov"
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email=EMAIL,
phone="(555) 123 12345",
title="Treat inspector",
)
BCC_EMAIL = settings.DEFAULT_FROM_EMAIL
User.objects.filter(email=EMAIL).delete()
in_review = DomainRequest.DomainRequestStatus.IN_REVIEW
action_needed = DomainRequest.DomainRequestStatus.ACTION_NEEDED
# Create a sample domain request
domain_request = completed_domain_request(status=in_review)
domain_request = completed_domain_request(status=in_review, user=_creator)
# Test the email sent out for already_has_domains
already_has_domains = DomainRequest.ActionNeededReasons.ALREADY_HAS_DOMAINS
@ -702,7 +708,7 @@ class TestDomainRequestAdmin(MockEppLib):
questionable_so = DomainRequest.ActionNeededReasons.QUESTIONABLE_SENIOR_OFFICIAL
self.transition_state_and_send_email(domain_request, action_needed, action_needed_reason=questionable_so)
self.assert_email_is_accurate(
"SENIOR OFFICIAL DOES NOT MEET ELIGIBILITY REQUIREMENTS", 3, EMAIL, bcc_email_address=BCC_EMAIL
"SENIOR OFFICIAL DOES NOT MEET ELIGIBILITY REQUIREMENTS", 3, _creator.email, bcc_email_address=BCC_EMAIL
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 4)
@ -723,7 +729,7 @@ class TestDomainRequestAdmin(MockEppLib):
)
domain_request.refresh_from_db()
self.assert_email_is_accurate("custom email content", 4, EMAIL, bcc_email_address=BCC_EMAIL)
self.assert_email_is_accurate("custom email content", 4, _creator.email, bcc_email_address=BCC_EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 5)
# Tests if a new email gets sent when just the email is changed.
@ -747,7 +753,9 @@ class TestDomainRequestAdmin(MockEppLib):
action_needed_reason=eligibility_unclear,
action_needed_reason_email="custom content when starting anew",
)
self.assert_email_is_accurate("custom content when starting anew", 5, EMAIL, bcc_email_address=BCC_EMAIL)
self.assert_email_is_accurate(
"custom content when starting anew", 5, _creator.email, bcc_email_address=BCC_EMAIL
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 6)
# def test_action_needed_sends_reason_email_prod_bcc(self):
@ -811,22 +819,31 @@ class TestDomainRequestAdmin(MockEppLib):
Also test that the default email set in settings is NOT BCCd on non-prod whenever
an email does go out."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
EMAIL = "meoward.jones@igorville.gov"
# Create a sample domain request
domain_request = completed_domain_request()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email=EMAIL,
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Test Submitted Status from started
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, True)
self.assert_email_is_accurate("We received your .gov domain request.", 0, _creator.email, True)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assert_email_is_accurate(
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, EMAIL, True
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, _creator.email, True
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@ -885,30 +902,37 @@ class TestDomainRequestAdmin(MockEppLib):
Also test that the default email set in settings IS BCCd on prod whenever
an email does go out."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
BCC_EMAIL = settings.DEFAULT_FROM_EMAIL
# Create a sample domain request
domain_request = completed_domain_request()
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Test Submitted Status from started
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, False, BCC_EMAIL)
self.assert_email_is_accurate("We received your .gov domain request.", 0, _creator.email, False, BCC_EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assert_email_is_accurate(
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, EMAIL
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 1, _creator.email
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (from withdrawn)
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 0, EMAIL, False, BCC_EMAIL)
self.assert_email_is_accurate("We received your .gov domain request.", 0, _creator.email, False, BCC_EMAIL)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
# Move it to IN_REVIEW
@ -933,21 +957,29 @@ class TestDomainRequestAdmin(MockEppLib):
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 3)
@override_flag("profile_feature", True)
@less_console_noise_decorator
def test_save_model_sends_approved_email(self):
"""When transitioning to approved on a domain request,
an email is sent out every time."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Test Submitted Status
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 0, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 0, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status
@ -956,7 +988,7 @@ class TestDomainRequestAdmin(MockEppLib):
DomainRequest.DomainRequestStatus.REJECTED,
DomainRequest.RejectionReasons.DOMAIN_PURPOSE,
)
self.assert_email_is_accurate("Your .gov domain request has been rejected.", 1, EMAIL)
self.assert_email_is_accurate("Your .gov domain request has been rejected.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (No new email should be sent)
@ -968,12 +1000,19 @@ class TestDomainRequestAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is domain purpose."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason DOMAIN_PURPOSE and test email
self.transition_state_and_send_email(
@ -984,13 +1023,13 @@ class TestDomainRequestAdmin(MockEppLib):
self.assert_email_is_accurate(
"Your domain request was rejected because the purpose you provided did not meet our \nrequirements.",
0,
EMAIL,
_creator.email,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
@ -998,12 +1037,19 @@ class TestDomainRequestAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is requestor."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason REQUESTOR and test email including dynamic organization name
self.transition_state_and_send_email(
@ -1013,13 +1059,13 @@ class TestDomainRequestAdmin(MockEppLib):
"Your domain request was rejected because we dont believe youre eligible to request a \n.gov "
"domain on behalf of Testorg",
0,
EMAIL,
_creator.email,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
@ -1027,12 +1073,19 @@ class TestDomainRequestAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is second domain."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason SECOND_DOMAIN_REASONING and test email including dynamic organization name
self.transition_state_and_send_email(
@ -1040,25 +1093,35 @@ class TestDomainRequestAdmin(MockEppLib):
DomainRequest.DomainRequestStatus.REJECTED,
DomainRequest.RejectionReasons.SECOND_DOMAIN_REASONING,
)
self.assert_email_is_accurate("Your domain request was rejected because Testorg has a .gov domain.", 0, EMAIL)
self.assert_email_is_accurate(
"Your domain request was rejected because Testorg has a .gov domain.", 0, _creator.email
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
def test_save_model_sends_rejected_email_contacts_or_org_legitimacy(self):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is contacts or org legitimacy."""
# Create fake creator
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
EMAIL = "meoward.jones@igorville.gov"
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email=EMAIL,
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason CONTACTS_OR_ORGANIZATION_LEGITIMACY and test email including dynamic organization name
self.transition_state_and_send_email(
@ -1070,13 +1133,13 @@ class TestDomainRequestAdmin(MockEppLib):
"Your domain request was rejected because we could not verify the organizational \n"
"contacts you provided. If you have questions or comments, reply to this email.",
0,
EMAIL,
_creator.email,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
@ -1084,12 +1147,19 @@ class TestDomainRequestAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is org eligibility."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason ORGANIZATION_ELIGIBILITY and test email including dynamic organization name
self.transition_state_and_send_email(
@ -1101,26 +1171,32 @@ class TestDomainRequestAdmin(MockEppLib):
"Your domain request was rejected because we determined that Testorg is not \neligible for "
"a .gov domain.",
0,
EMAIL,
_creator.email,
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
def test_save_model_sends_rejected_email_naming(self):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is naming."""
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason NAMING_REQUIREMENTS and test email including dynamic organization name
self.transition_state_and_send_email(
@ -1129,13 +1205,13 @@ class TestDomainRequestAdmin(MockEppLib):
DomainRequest.RejectionReasons.NAMING_REQUIREMENTS,
)
self.assert_email_is_accurate(
"Your domain request was rejected because it does not meet our naming requirements.", 0, EMAIL
"Your domain request was rejected because it does not meet our naming requirements.", 0, _creator.email
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
@ -1143,12 +1219,19 @@ class TestDomainRequestAdmin(MockEppLib):
"""When transitioning to rejected on a domain request, an email is sent
explaining why when the reason is other."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelist user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Reject for reason NAMING_REQUIREMENTS and test email including dynamic organization name
self.transition_state_and_send_email(
@ -1156,12 +1239,12 @@ class TestDomainRequestAdmin(MockEppLib):
DomainRequest.DomainRequestStatus.REJECTED,
DomainRequest.RejectionReasons.OTHER,
)
self.assert_email_is_accurate("Choosing a .gov domain name", 0, EMAIL)
self.assert_email_is_accurate("Choosing a .gov domain name", 0, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Approve
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.APPROVED)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, EMAIL)
self.assert_email_is_accurate("Congratulations! Your .gov domain request has been approved.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
@less_console_noise_decorator
@ -1225,23 +1308,30 @@ class TestDomainRequestAdmin(MockEppLib):
"""When transitioning to withdrawn on a domain request,
an email is sent out every time."""
# Ensure there is no user with this email
EMAIL = "mayor@igorville.gov"
User.objects.filter(email=EMAIL).delete()
# Create fake creator
_creator = User.objects.create(
username="MrMeoward",
first_name="Meoward",
last_name="Jones",
email="meoward.jones@igorville.gov",
phone="(555) 123 12345",
title="Treat inspector",
)
# Create a sample domain request
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW)
# Create a sample domain request and whitelists user email
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.IN_REVIEW, user=_creator)
AllowedEmail.objects.get_or_create(email=_creator.email)
# Test Submitted Status
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.WITHDRAWN)
self.assert_email_is_accurate(
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 0, EMAIL
"Your .gov domain request has been withdrawn and will not be reviewed by our team.", 0, _creator.email
)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 1)
# Test Withdrawn Status
self.transition_state_and_send_email(domain_request, DomainRequest.DomainRequestStatus.SUBMITTED)
self.assert_email_is_accurate("We received your .gov domain request.", 1, EMAIL)
self.assert_email_is_accurate("We received your .gov domain request.", 1, _creator.email)
self.assertEqual(len(self.mock_client.EMAILS_SENT), 2)
# Test Submitted Status Again (No new email should be sent)
@ -1420,16 +1510,6 @@ class TestDomainRequestAdmin(MockEppLib):
# Check for the field itself
self.assertContains(response, "Meoward Jones")
# == Check for the submitter == #
self.assertContains(response, "mayor@igorville.gov", count=2)
expected_submitter_fields = [
# Field, expected value
("title", "Admin Tester"),
("phone", "(555) 555 5556"),
]
self.test_helper.assert_response_contains_distinct_values(response, expected_submitter_fields)
self.assertContains(response, "Testy2 Tester2")
# == Check for the senior_official == #
self.assertContains(response, "testy@town.com", count=2)
expected_so_fields = [
@ -1450,7 +1530,7 @@ class TestDomainRequestAdmin(MockEppLib):
self.test_helper.assert_response_contains_distinct_values(response, expected_other_employees_fields)
# Test for the copy link
self.assertContains(response, "button--clipboard", count=5)
self.assertContains(response, "button--clipboard", count=4)
# Test that Creator counts display properly
self.assertNotContains(response, "Approved domains")
@ -1585,7 +1665,6 @@ class TestDomainRequestAdmin(MockEppLib):
"senior_official",
"approved_domain",
"requested_domain",
"submitter",
"purpose",
"no_other_contacts_rationale",
"anything_else",
@ -1624,7 +1703,6 @@ class TestDomainRequestAdmin(MockEppLib):
"approved_domain",
"alternative_domains",
"purpose",
"submitter",
"no_other_contacts_rationale",
"anything_else",
"is_policy_acknowledged",

View file

@ -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
@ -93,7 +93,6 @@ class TestEmails(TestCase):
# check for optional things
self.assertIn("Other employees from your organization:", body)
self.assertIn("Testy2 Tester2", body)
self.assertIn("Current websites:", body)
self.assertIn("city.com", body)
self.assertIn("About your organization:", body)
@ -130,14 +129,20 @@ 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"5556\n\nOther employees")
self.assertRegex(body, r"8888\n\nOther employees")
self.assertRegex(body, r"5557\n\nAnything else")
@boto3_mocking.patching
@ -150,7 +155,6 @@ class TestEmails(TestCase):
_, kwargs = self.mock_client.send_email.call_args
body = kwargs["Content"]["Simple"]["Body"]["Text"]["Data"]
# spacing should be right between adjacent elements
self.assertRegex(body, r"5556\n\nOther employees")
self.assertRegex(body, r"None\n\nAnything else")
@boto3_mocking.patching

View file

@ -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"})

View file

@ -170,7 +170,6 @@ class TestDomainRequest(TestCase):
zipcode="12345-6789",
senior_official=contact,
requested_domain=domain,
submitter=contact,
purpose="Igorville rules!",
anything_else="All of Igorville loves the dotgov program.",
is_policy_acknowledged=True,
@ -197,7 +196,6 @@ class TestDomainRequest(TestCase):
state_territory="CA",
zipcode="12345-6789",
senior_official=contact,
submitter=contact,
purpose="Igorville rules!",
anything_else="All of Igorville loves the dotgov program.",
is_policy_acknowledged=True,
@ -225,7 +223,7 @@ class TestDomainRequest(TestCase):
site = DraftDomain.objects.create(name="igorville.gov")
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 less_console_noise():
@ -262,15 +260,17 @@ class TestDomainRequest(TestCase):
@less_console_noise_decorator
def test_submit_from_started_sends_email(self):
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)
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hello")
domain_request = completed_domain_request(user=self.dummy_user_2)
self.check_email_sent(
domain_request, msg, "submit", 1, expected_content="Lava", expected_email=self.dummy_user_2.email
)
@override_flag("profile_feature", active=True)
@less_console_noise_decorator
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"""
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(
domain_request, msg, "submit", 1, expected_content="Lava", expected_email="intern@igorville.com"
)
@ -278,10 +278,9 @@ class TestDomainRequest(TestCase):
@less_console_noise_decorator
def test_submit_from_withdrawn_sends_email(self):
msg = "Create a withdrawn domain request and submit it and see if email was sent."
domain_request = completed_domain_request(
status=DomainRequest.DomainRequestStatus.WITHDRAWN, submitter=self.dummy_user
)
self.check_email_sent(domain_request, msg, "submit", 1, expected_content="Hello")
user, _ = User.objects.get_or_create(username="testy")
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)
@less_console_noise_decorator
def test_submit_from_action_needed_does_not_send_email(self):
@ -298,26 +297,25 @@ class TestDomainRequest(TestCase):
@less_console_noise_decorator
def test_approve_sends_email(self):
msg = "Create a domain request and approve it and see if email was sent."
domain_request = completed_domain_request(
status=DomainRequest.DomainRequestStatus.IN_REVIEW, submitter=self.dummy_user
)
self.check_email_sent(domain_request, msg, "approve", 1, expected_content="Hello")
user, _ = User.objects.get_or_create(username="testy")
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)
@less_console_noise_decorator
def test_withdraw_sends_email(self):
msg = "Create a domain request and withdraw it and see if email was sent."
domain_request = completed_domain_request(
status=DomainRequest.DomainRequestStatus.IN_REVIEW, submitter=self.dummy_user
user, _ = User.objects.get_or_create(username="testy")
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
def test_reject_sends_email(self):
msg = "Create a domain request and reject it and see if email was sent."
domain_request = completed_domain_request(
status=DomainRequest.DomainRequestStatus.APPROVED, submitter=self.dummy_user
)
self.check_email_sent(domain_request, msg, "reject", 1, expected_content="Hello")
user, _ = User.objects.get_or_create(username="testy")
domain_request = completed_domain_request(status=DomainRequest.DomainRequestStatus.APPROVED, user=user)
self.check_email_sent(domain_request, msg, "reject", 1, expected_content="Hi", expected_email=user.email)
@less_console_noise_decorator
def test_reject_with_prejudice_does_not_send_email(self):
@ -2139,7 +2137,6 @@ class TestDomainRequestIncomplete(TestCase):
senior_official=so,
requested_domain=draft_domain,
purpose="Some purpose",
submitter=you,
no_other_contacts_rationale=None,
has_cisa_representative=True,
cisa_representative_email="somerep@cisa.com",
@ -2268,13 +2265,6 @@ class TestDomainRequestIncomplete(TestCase):
self.domain_request.save()
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
def test_is_other_contacts_complete_missing_one_field(self):
self.assertTrue(self.domain_request._is_other_contacts_complete())

View file

@ -369,19 +369,12 @@ class HomeTests(TestWithUser):
last_name="Mars",
)
# Attach a user object to a contact (should not be deleted)
contact_user, _ = Contact.objects.get_or_create(
first_name="Hank",
last_name="McFakey",
)
site = DraftDomain.objects.create(name="igorville.gov")
domain_request = DomainRequest.objects.create(
creator=self.user,
requested_domain=site,
status=DomainRequest.DomainRequestStatus.WITHDRAWN,
senior_official=contact,
submitter=contact_user,
)
domain_request.other_contacts.set([contact_2])
@ -392,7 +385,6 @@ class HomeTests(TestWithUser):
requested_domain=site_2,
status=DomainRequest.DomainRequestStatus.STARTED,
senior_official=contact_2,
submitter=contact_shared,
)
domain_request_2.other_contacts.set([contact_shared])
@ -409,8 +401,6 @@ class HomeTests(TestWithUser):
# Check if the orphaned contacts were deleted
orphan = Contact.objects.filter(id=contact.id)
self.assertFalse(orphan.exists())
orphan = Contact.objects.filter(id=contact_user.id)
self.assertFalse(orphan.exists())
try:
edge_case = Contact.objects.filter(id=contact_2.id).get()
@ -455,7 +445,6 @@ class HomeTests(TestWithUser):
requested_domain=site,
status=DomainRequest.DomainRequestStatus.WITHDRAWN,
senior_official=contact,
submitter=contact_user,
)
domain_request.other_contacts.set([contact_2])
@ -466,7 +455,6 @@ class HomeTests(TestWithUser):
requested_domain=site_2,
status=DomainRequest.DomainRequestStatus.STARTED,
senior_official=contact_2,
submitter=contact_shared,
)
domain_request_2.other_contacts.set([contact_shared])
@ -1010,20 +998,6 @@ class UserProfileTests(TestWithUser, WebTest):
self.assertContains(response, "Your profile")
self.assertNotContains(response, "Your contact information")
@less_console_noise_decorator
def test_domain_your_contact_information_when_profile_feature_off(self):
"""test that Your contact information is accessible when profile_feature is off"""
with override_flag("profile_feature", active=False):
response = self.client.get(f"/domain/{self.domain.id}/your-contact-information", follow=True)
self.assertContains(response, "Your contact information")
@less_console_noise_decorator
def test_domain_your_contact_information_when_profile_feature_on(self):
"""test that Your contact information is not accessible when profile feature is on"""
with override_flag("profile_feature", active=True):
response = self.client.get(f"/domain/{self.domain.id}/your-contact-information", follow=True)
self.assertEqual(response.status_code, 404)
@less_console_noise_decorator
def test_request_when_profile_feature_on(self):
"""test that Your profile is in request page when profile feature is on"""
@ -1038,7 +1012,6 @@ class UserProfileTests(TestWithUser, WebTest):
requested_domain=site,
status=DomainRequest.DomainRequestStatus.SUBMITTED,
senior_official=contact_user,
submitter=contact_user,
)
with override_flag("profile_feature", active=True):
response = self.client.get(f"/domain-request/{domain_request.id}", follow=True)
@ -1060,7 +1033,6 @@ class UserProfileTests(TestWithUser, WebTest):
requested_domain=site,
status=DomainRequest.DomainRequestStatus.SUBMITTED,
senior_official=contact_user,
submitter=contact_user,
)
with override_flag("profile_feature", active=False):
response = self.client.get(f"/domain-request/{domain_request.id}", follow=True)

View file

@ -161,7 +161,6 @@ class TestDomainPermissions(TestWithDomainPermissions):
"domain-dns-nameservers",
"domain-org-name-address",
"domain-senior-official",
"domain-your-contact-information",
"domain-security-email",
]:
with self.subTest(view_name=view_name):
@ -181,7 +180,6 @@ class TestDomainPermissions(TestWithDomainPermissions):
"domain-dns-nameservers",
"domain-org-name-address",
"domain-senior-official",
"domain-your-contact-information",
"domain-security-email",
]:
with self.subTest(view_name=view_name):
@ -202,7 +200,6 @@ class TestDomainPermissions(TestWithDomainPermissions):
"domain-dns-dnssec-dsdata",
"domain-org-name-address",
"domain-senior-official",
"domain-your-contact-information",
"domain-security-email",
]:
for domain in [
@ -1624,22 +1621,6 @@ class TestDomainSuborganization(TestDomainOverview):
portfolio.delete()
class TestDomainContactInformation(TestDomainOverview):
@less_console_noise_decorator
def test_domain_your_contact_information(self):
"""Can load domain's your contact information page."""
page = self.client.get(reverse("domain-your-contact-information", kwargs={"pk": self.domain.id}))
self.assertContains(page, "Your contact information")
@less_console_noise_decorator
def test_domain_your_contact_information_content(self):
"""Logged-in user's contact information appears on the page."""
self.user.first_name = "Testy"
self.user.save()
page = self.app.get(reverse("domain-your-contact-information", kwargs={"pk": self.domain.id}))
self.assertContains(page, "Testy")
class TestDomainSecurityEmail(TestDomainOverview):
def test_domain_security_email_existing_security_contact(self):
"""Can load domain's security email page."""

View file

@ -8,6 +8,7 @@ from .common import MockSESClient, completed_domain_request # type: ignore
from django_webtest import WebTest # type: ignore
import boto3_mocking # type: ignore
from waffle.testutils import override_flag
from registrar.models import (
DomainRequest,
DraftDomain,
@ -350,41 +351,13 @@ class DomainRequestTests(TestWithUser, WebTest):
# the post request should return a redirect to the next form in
# the domain request page
self.assertEqual(purpose_result.status_code, 302)
self.assertEqual(purpose_result["Location"], "/request/your_contact/")
num_pages_tested += 1
# ---- YOUR CONTACT INFO PAGE ----
# Follow the redirect to the next form page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_page = purpose_result.follow()
your_contact_form = your_contact_page.forms[0]
your_contact_form["your_contact-first_name"] = "Testy you"
your_contact_form["your_contact-last_name"] = "Tester you"
your_contact_form["your_contact-title"] = "Admin Tester"
your_contact_form["your_contact-email"] = "testy-admin@town.com"
your_contact_form["your_contact-phone"] = "(201) 555 5556"
# test next button
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_result = your_contact_form.submit()
# validate that data from this step are being saved
domain_request = DomainRequest.objects.get() # there's only one
self.assertEqual(domain_request.submitter.first_name, "Testy you")
self.assertEqual(domain_request.submitter.last_name, "Tester you")
self.assertEqual(domain_request.submitter.title, "Admin Tester")
self.assertEqual(domain_request.submitter.email, "testy-admin@town.com")
self.assertEqual(domain_request.submitter.phone, "(201) 555 5556")
# the post request should return a redirect to the next form in
# the domain request page
self.assertEqual(your_contact_result.status_code, 302)
self.assertEqual(your_contact_result["Location"], "/request/other_contacts/")
self.assertEqual(purpose_result["Location"], "/request/other_contacts/")
num_pages_tested += 1
# ---- OTHER CONTACTS PAGE ----
# Follow the redirect to the next form page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
other_contacts_page = your_contact_result.follow()
other_contacts_page = purpose_result.follow()
# This page has 3 forms in 1.
# Let's set the yes/no radios to enable the other contacts fieldsets
@ -494,11 +467,6 @@ class DomainRequestTests(TestWithUser, WebTest):
self.assertContains(review_page, "city.gov")
self.assertContains(review_page, "city1.gov")
self.assertContains(review_page, "For all kinds of things.")
self.assertContains(review_page, "Testy you")
self.assertContains(review_page, "Tester you")
self.assertContains(review_page, "Admin Tester")
self.assertContains(review_page, "testy-admin@town.com")
self.assertContains(review_page, "(201) 555-5556")
self.assertContains(review_page, "Testy2")
self.assertContains(review_page, "Tester2")
self.assertContains(review_page, "Another Tester")
@ -706,41 +674,13 @@ class DomainRequestTests(TestWithUser, WebTest):
# the post request should return a redirect to the next form in
# the domain request page
self.assertEqual(purpose_result.status_code, 302)
self.assertEqual(purpose_result["Location"], "/request/your_contact/")
num_pages_tested += 1
# ---- YOUR CONTACT INFO PAGE ----
# Follow the redirect to the next form page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_page = purpose_result.follow()
your_contact_form = your_contact_page.forms[0]
your_contact_form["your_contact-first_name"] = "Testy you"
your_contact_form["your_contact-last_name"] = "Tester you"
your_contact_form["your_contact-title"] = "Admin Tester"
your_contact_form["your_contact-email"] = "testy-admin@town.com"
your_contact_form["your_contact-phone"] = "(201) 555 5556"
# test next button
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_result = your_contact_form.submit()
# validate that data from this step are being saved
domain_request = DomainRequest.objects.get() # there's only one
self.assertEqual(domain_request.submitter.first_name, "Testy you")
self.assertEqual(domain_request.submitter.last_name, "Tester you")
self.assertEqual(domain_request.submitter.title, "Admin Tester")
self.assertEqual(domain_request.submitter.email, "testy-admin@town.com")
self.assertEqual(domain_request.submitter.phone, "(201) 555 5556")
# the post request should return a redirect to the next form in
# the domain request page
self.assertEqual(your_contact_result.status_code, 302)
self.assertEqual(your_contact_result["Location"], "/request/other_contacts/")
self.assertEqual(purpose_result["Location"], "/request/other_contacts/")
num_pages_tested += 1
# ---- OTHER CONTACTS PAGE ----
# Follow the redirect to the next form page
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
other_contacts_page = your_contact_result.follow()
other_contacts_page = purpose_result.follow()
# This page has 3 forms in 1.
# Let's set the yes/no radios to enable the other contacts fieldsets
@ -1645,7 +1585,6 @@ class DomainRequestTests(TestWithUser, WebTest):
state_territory="NY",
zipcode="10002",
senior_official=so,
submitter=you,
creator=self.user,
status="started",
)
@ -1782,7 +1721,6 @@ class DomainRequestTests(TestWithUser, WebTest):
state_territory="NY",
zipcode="10002",
senior_official=so,
submitter=you,
creator=self.user,
status="started",
)
@ -1857,7 +1795,6 @@ class DomainRequestTests(TestWithUser, WebTest):
state_territory="NY",
zipcode="10002",
senior_official=so,
submitter=you,
creator=self.user,
status="started",
)
@ -1935,7 +1872,6 @@ class DomainRequestTests(TestWithUser, WebTest):
state_territory="NY",
zipcode="10002",
senior_official=so,
submitter=you,
creator=self.user,
status="started",
)
@ -2012,7 +1948,6 @@ class DomainRequestTests(TestWithUser, WebTest):
state_territory="NY",
zipcode="10002",
senior_official=so,
submitter=you,
creator=self.user,
status="started",
)
@ -2088,7 +2023,6 @@ class DomainRequestTests(TestWithUser, WebTest):
state_territory="NY",
zipcode="10002",
senior_official=so,
submitter=you,
creator=self.user,
status="started",
)
@ -2272,23 +2206,15 @@ class DomainRequestTests(TestWithUser, WebTest):
senior_official = domain_request.senior_official
self.assertEquals("Testy2", senior_official.first_name)
@override_flag("profile_feature", active=True)
@less_console_noise_decorator
def test_edit_submitter_in_place(self):
def test_edit_creator_in_place(self):
"""When you:
1. edit a submitter (your contact) which is not joined to another model,
1. edit a your user profile information,
2. then submit,
the domain request is linked to the existing submitter, and the submitter updated."""
the domain request also updates its creator data to reflect user profile changes."""
# Populate the database with a domain request that
# has a submitter
# We'll do it from scratch
you, _ = Contact.objects.get_or_create(
first_name="Testy",
last_name="Tester",
title="Chief Tester",
email="testy@town.com",
phone="(201) 555 5555",
)
# Populate the database with a domain request
domain_request, _ = DomainRequest.objects.get_or_create(
generic_org_type="federal",
federal_type="executive",
@ -2299,14 +2225,11 @@ class DomainRequestTests(TestWithUser, WebTest):
address_line1="address 1",
state_territory="NY",
zipcode="10002",
submitter=you,
creator=self.user,
status="started",
)
# submitter_pk is the initial pk of the submitter. set it before update
# to be able to verify after update that the same contact object is in place
submitter_pk = you.id
creator_pk = self.user.id
# prime the form by visiting /edit
self.app.get(reverse("edit-domain-request", kwargs={"id": domain_request.pk}))
@ -2317,98 +2240,25 @@ class DomainRequestTests(TestWithUser, WebTest):
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_page = self.app.get(reverse("domain-request:your_contact"))
profile_page = self.app.get("/user-profile")
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_form = your_contact_page.forms[0]
profile_form = profile_page.forms[0]
# Minimal check to ensure the form is loaded
self.assertEqual(your_contact_form["your_contact-first_name"].value, "Testy")
self.assertEqual(profile_form["first_name"].value, self.user.first_name)
# update the first name of the contact
your_contact_form["your_contact-first_name"] = "Testy2"
profile_form["first_name"] = "Testy2"
# Submit the updated form
your_contact_form.submit()
profile_form.submit()
domain_request.refresh_from_db()
updated_submitter = domain_request.submitter
self.assertEquals(submitter_pk, updated_submitter.id)
self.assertEquals("Testy2", updated_submitter.first_name)
@less_console_noise_decorator
def test_edit_submitter_creates_new(self):
"""When you:
1. edit an existing your contact which IS joined to another model,
2. then submit,
the domain request is linked to a new Contact, and the new Contact is updated."""
# Populate the database with a domain request that
# has submitter assigned to it, the submitter is also
# an other contact initially
# We'll do it from scratch
submitter, _ = Contact.objects.get_or_create(
first_name="Testy",
last_name="Tester",
title="Chief Tester",
email="testy@town.com",
phone="(201) 555 5555",
)
domain_request, _ = DomainRequest.objects.get_or_create(
generic_org_type="federal",
federal_type="executive",
purpose="Purpose of the site",
anything_else="No",
is_policy_acknowledged=True,
organization_name="Testorg",
address_line1="address 1",
state_territory="NY",
zipcode="10002",
submitter=submitter,
creator=self.user,
status="started",
)
domain_request.other_contacts.add(submitter)
# submitter_pk is the initial pk of the your contact. set it before update
# to be able to verify after update that the other contact is still in place
# and not updated, and that the new submitter has a new id
submitter_pk = submitter.id
# prime the form by visiting /edit
self.app.get(reverse("edit-domain-request", kwargs={"id": domain_request.pk}))
# django-webtest does not handle cookie-based sessions well because it keeps
# resetting the session key on each new request, thus destroying the concept
# of a "session". We are going to do it manually, saving the session ID here
# and then setting the cookie on each request.
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_page = self.app.get(reverse("domain-request:your_contact"))
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
your_contact_form = your_contact_page.forms[0]
# Minimal check to ensure the form is loaded
self.assertEqual(your_contact_form["your_contact-first_name"].value, "Testy")
# update the first name of the contact
your_contact_form["your_contact-first_name"] = "Testy2"
# Submit the updated form
your_contact_form.submit()
domain_request.refresh_from_db()
# assert that the other contact is not updated
other_contacts = domain_request.other_contacts.all()
other_contact = other_contacts[0]
self.assertEquals(submitter_pk, other_contact.id)
self.assertEquals("Testy", other_contact.first_name)
# assert that the submitter is updated
submitter = domain_request.submitter
self.assertEquals("Testy2", submitter.first_name)
updated_creator = domain_request.creator
self.assertEquals(creator_pk, updated_creator.id)
self.assertEquals("Testy2", updated_creator.first_name)
@less_console_noise_decorator
def test_domain_request_about_your_organiztion_interstate(self):
@ -2731,7 +2581,6 @@ class DomainRequestTests(TestWithUser, WebTest):
zipcode="10002",
senior_official=so,
requested_domain=domain,
submitter=you,
creator=self.user,
)
domain_request.other_contacts.add(other)
@ -2876,7 +2725,6 @@ class DomainRequestTestDifferentStatuses(TestWithUser, WebTest):
self.assertContains(detail_page, "city1.gov")
self.assertContains(detail_page, "Chief Tester")
self.assertContains(detail_page, "testy@town.com")
self.assertContains(detail_page, "Admin Tester")
self.assertContains(detail_page, "Status:")
@less_console_noise_decorator
@ -2893,7 +2741,6 @@ class DomainRequestTestDifferentStatuses(TestWithUser, WebTest):
self.assertContains(detail_page, "city.gov")
self.assertContains(detail_page, "Chief Tester")
self.assertContains(detail_page, "testy@town.com")
self.assertContains(detail_page, "Admin Tester")
self.assertContains(detail_page, "Status:")
@less_console_noise_decorator
@ -2907,7 +2754,6 @@ class DomainRequestTestDifferentStatuses(TestWithUser, WebTest):
self.assertContains(detail_page, "city1.gov")
self.assertContains(detail_page, "Chief Tester")
self.assertContains(detail_page, "testy@town.com")
self.assertContains(detail_page, "Admin Tester")
self.assertContains(detail_page, "Status:")
# click the "Withdraw request" button
mock_client = MockSESClient()
@ -2943,7 +2789,6 @@ class DomainRequestTestDifferentStatuses(TestWithUser, WebTest):
self.assertContains(detail_page, "city1.gov")
self.assertContains(detail_page, "Chief Tester")
self.assertContains(detail_page, "testy@town.com")
self.assertContains(detail_page, "Admin Tester")
self.assertContains(detail_page, "Status:")
# click the "Withdraw request" button
mock_client = MockSESClient()
@ -2973,7 +2818,6 @@ class DomainRequestTestDifferentStatuses(TestWithUser, WebTest):
self.assertContains(detail_page, "city1.gov")
self.assertContains(detail_page, "Chief Tester")
self.assertContains(detail_page, "testy@town.com")
self.assertContains(detail_page, "Admin Tester")
self.assertContains(detail_page, "Status:")
# Restricted user trying to withdraw results in 403 error
with less_console_noise():
@ -3072,10 +2916,10 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
self.assertEqual(detail_page.status_code, 200)
# 10 unlocked steps, one active step, the review step will have link_usa but not check_circle
self.assertContains(detail_page, "#check_circle", count=10)
self.assertContains(detail_page, "#check_circle", count=9)
# Type of organization
self.assertContains(detail_page, "usa-current", count=1)
self.assertContains(detail_page, "link_usa-checked", count=11)
self.assertContains(detail_page, "link_usa-checked", count=10)
else:
self.fail(f"Expected a redirect, but got a different response: {response}")
@ -3107,7 +2951,6 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
requested_domain=site,
status=DomainRequest.DomainRequestStatus.WITHDRAWN,
senior_official=contact,
submitter=contact_user,
)
domain_request.other_contacts.set([contact_2])
@ -3133,12 +2976,12 @@ class TestWizardUnlockingSteps(TestWithUser, WebTest):
# Now 'detail_page' contains the response after following the redirect
self.assertEqual(detail_page.status_code, 200)
# 5 unlocked steps (so, domain, submitter, other contacts, and current sites
# 5 unlocked steps (so, domain, other contacts, and current sites
# which unlocks if domain exists), one active step, the review step is locked
self.assertContains(detail_page, "#check_circle", count=5)
self.assertContains(detail_page, "#check_circle", count=4)
# Type of organization
self.assertContains(detail_page, "usa-current", count=1)
self.assertContains(detail_page, "link_usa-checked", count=5)
self.assertContains(detail_page, "link_usa-checked", count=4)
else:
self.fail(f"Expected a redirect, but got a different response: {response}")

View file

@ -77,17 +77,15 @@ class FSMErrorCodes(IntEnum):
- 1 APPROVE_DOMAIN_IN_USE The domain is already in use
- 2 NO_INVESTIGATOR No investigator is assigned
- 3 INVESTIGATOR_NOT_STAFF Investigator is a non-staff user
- 4 INVESTIGATOR_NOT_SUBMITTER The form submitter is not the investigator
- 5 NO_REJECTION_REASON No rejection reason is specified
- 6 NO_ACTION_NEEDED_REASON No action needed reason is specified
- 4 NO_REJECTION_REASON No rejection reason is specified
- 5 NO_ACTION_NEEDED_REASON No action needed reason is specified
"""
APPROVE_DOMAIN_IN_USE = 1
NO_INVESTIGATOR = 2
INVESTIGATOR_NOT_STAFF = 3
INVESTIGATOR_NOT_SUBMITTER = 4
NO_REJECTION_REASON = 5
NO_ACTION_NEEDED_REASON = 6
NO_REJECTION_REASON = 4
NO_ACTION_NEEDED_REASON = 5
class FSMDomainRequestError(Exception):
@ -100,7 +98,6 @@ class FSMDomainRequestError(Exception):
FSMErrorCodes.APPROVE_DOMAIN_IN_USE: ("Cannot approve. Requested domain is already in use."),
FSMErrorCodes.NO_INVESTIGATOR: ("Investigator is required for this status."),
FSMErrorCodes.INVESTIGATOR_NOT_STAFF: ("Investigator is not a staff user."),
FSMErrorCodes.INVESTIGATOR_NOT_SUBMITTER: ("Only the assigned investigator can make this change."),
FSMErrorCodes.NO_REJECTION_REASON: ("A reason is required for this status."),
FSMErrorCodes.NO_ACTION_NEEDED_REASON: ("A reason is required for this status."),
}

View file

@ -8,7 +8,6 @@ from .domain import (
DomainNameserversView,
DomainDNSSECView,
DomainDsDataView,
DomainYourContactInformationView,
DomainSecurityEmailView,
DomainUsersView,
DomainAddUserView,

View file

@ -40,7 +40,6 @@ from registrar.models.utility.contact_error import ContactError
from registrar.views.utility.permission_views import UserDomainRolePermissionDeleteView
from ..forms import (
UserForm,
SeniorOfficialContactForm,
DomainOrgNameAddressForm,
DomainAddUserForm,
@ -59,7 +58,6 @@ from epplibwrapper import (
from ..utility.email import send_templated_email, EmailSendingError
from .utility import DomainPermissionView, DomainInvitationPermissionDeleteView
from waffle.decorators import waffle_flag
logger = logging.getLogger(__name__)
@ -641,38 +639,6 @@ class DomainDsDataView(DomainFormBaseView):
return super().form_valid(formset)
class DomainYourContactInformationView(DomainFormBaseView):
"""Domain your contact information editing view."""
template_name = "domain_your_contact_information.html"
form_class = UserForm
@waffle_flag("!profile_feature") # type: ignore
def dispatch(self, request, *args, **kwargs): # type: ignore
return super().dispatch(request, *args, **kwargs)
def get_form_kwargs(self, *args, **kwargs):
"""Add domain_info.submitter instance to make a bound form."""
form_kwargs = super().get_form_kwargs(*args, **kwargs)
form_kwargs["instance"] = self.request.user
return form_kwargs
def get_success_url(self):
"""Redirect to the your contact information for the domain."""
return reverse("domain-your-contact-information", kwargs={"pk": self.object.pk})
def form_valid(self, form):
"""The form is valid, call setter in model."""
# Post to DB using values from the form
form.save()
messages.success(self.request, "Your contact information for all your domains has been updated.")
# superclass has the redirect
return super().form_valid(form)
class DomainSecurityEmailView(DomainFormBaseView):
"""Domain security email editing view."""

View file

@ -22,8 +22,6 @@ from .utility import (
DomainRequestWizardPermissionView,
)
from waffle.decorators import flag_is_active, waffle_flag
logger = logging.getLogger(__name__)
@ -45,7 +43,6 @@ class Step(StrEnum):
CURRENT_SITES = "current_sites"
DOTGOV_DOMAIN = "dotgov_domain"
PURPOSE = "purpose"
YOUR_CONTACT = "your_contact"
OTHER_CONTACTS = "other_contacts"
ADDITIONAL_DETAILS = "additional_details"
REQUIREMENTS = "requirements"
@ -91,7 +88,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
Step.CURRENT_SITES: _("Current websites"),
Step.DOTGOV_DOMAIN: _(".gov domain"),
Step.PURPOSE: _("Purpose of your domain"),
Step.YOUR_CONTACT: _("Your contact information"),
Step.OTHER_CONTACTS: _("Other employees from your organization"),
Step.ADDITIONAL_DETAILS: _("Additional details"),
Step.REQUIREMENTS: _("Requirements for operating a .gov domain"),
@ -382,7 +378,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
),
"dotgov_domain": self.domain_request.requested_domain is not None,
"purpose": self.domain_request.purpose is not None,
"your_contact": self.domain_request.submitter is not None,
"other_contacts": (
self.domain_request.other_contacts.exists()
or self.domain_request.no_other_contacts_rationale is not None
@ -452,9 +447,6 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
if condition:
step_list.append(step)
if flag_is_active(self.request, "profile_feature"):
step_list.remove(Step.YOUR_CONTACT)
return step_list
def goto(self, step):
@ -599,15 +591,6 @@ class Purpose(DomainRequestWizard):
forms = [forms.PurposeForm]
class YourContact(DomainRequestWizard):
template_name = "domain_request_your_contact.html"
forms = [forms.YourContactForm]
@waffle_flag("!profile_feature") # type: ignore
def dispatch(self, request, *args, **kwargs): # type: ignore
return super().dispatch(request, *args, **kwargs)
class OtherContacts(DomainRequestWizard):
template_name = "domain_request_other_contacts.html"
forms = [forms.OtherContactsYesNoForm, forms.OtherContactsFormSet, forms.NoOtherContactsForm]
@ -833,7 +816,7 @@ class DomainRequestDeleteView(DomainRequestPermissionDeleteView):
# After a delete occurs, do a second sweep on any returned duplicates.
# This determines if any of these three fields share a contact, which is used for
# the edge case where the same user may be an SO, and a submitter, for example.
# the edge case where the same user may be an SO, and a creator, for example.
if len(duplicates) > 0:
duplicates_to_delete, _ = self._get_orphaned_contacts(domain_request, check_db=True)
Contact.objects.filter(id__in=duplicates_to_delete).delete()
@ -846,7 +829,7 @@ class DomainRequestDeleteView(DomainRequestPermissionDeleteView):
Collects all orphaned contacts associated with a given DomainRequest object.
An orphaned contact is defined as a contact that is associated with the domain request,
but not with any other domain_request. This includes the senior official, the submitter,
but not with any other domain_request. This includes the senior official, the creator,
and any other contacts linked to the domain_request.
Parameters:
@ -862,18 +845,16 @@ class DomainRequestDeleteView(DomainRequestPermissionDeleteView):
# Get each contact object on the DomainRequest object
so = domain_request.senior_official
submitter = domain_request.submitter
other_contacts = list(domain_request.other_contacts.all())
other_contact_ids = domain_request.other_contacts.all().values_list("id", flat=True)
# Check if the desired item still exists in the DB
if check_db:
so = self._get_contacts_by_id([so.id]).first() if so is not None else None
submitter = self._get_contacts_by_id([submitter.id]).first() if submitter is not None else None
other_contacts = self._get_contacts_by_id(other_contact_ids)
# Pair each contact with its db related name for use in checking if it has joins
checked_contacts = [(so, "senior_official"), (submitter, "submitted_domain_requests")]
checked_contacts = [(so, "senior_official")]
checked_contacts.extend((contact, "contact_domain_requests") for contact in other_contacts)
for contact, related_name in checked_contacts:

View file

@ -81,12 +81,12 @@ class OrderableFieldsMixin:
Or for fields with multiple order_fields:
```
def get_sortable_submitter(self, obj):
return obj.submitter
def get_sortable_creator(self, obj):
return obj.creator
# Allows column order sorting
get_sortable_submitter.admin_order_field = ["submitter__first_name", "submitter__last_name"]
get_sortable_creator.admin_order_field = ["creator__first_name", "creator__last_name"]
# Sets column's header
get_sortable_submitter.short_description = "submitter"
get_sortable_creator.short_description = "creator"
```
Parameters:
@ -114,8 +114,8 @@ class OrderableFieldsMixin:
Returns (example):
```
def get_submitter(self, obj):
return obj.submitter
def get_creator(self, obj):
return obj.creator
```
"""
attr = getattr(obj, field)