mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-15 09:07:02 +02:00
Merge conflictts pt 1
This commit is contained in:
parent
ca1a79a97f
commit
a5a3c13653
4 changed files with 58 additions and 58 deletions
|
@ -139,17 +139,17 @@ class DomainRequestAdminForm(forms.ModelForm):
|
|||
|
||||
# We only care about investigator when in these statuses
|
||||
checked_statuses = [
|
||||
DomainApplication.ApplicationStatus.APPROVED,
|
||||
DomainApplication.ApplicationStatus.IN_REVIEW,
|
||||
DomainApplication.ApplicationStatus.ACTION_NEEDED,
|
||||
DomainApplication.ApplicationStatus.REJECTED,
|
||||
DomainApplication.ApplicationStatus.INELIGIBLE,
|
||||
DomainRequest.DomainRequestStatus.APPROVED,
|
||||
DomainRequest.DomainRequestStatus.IN_REVIEW,
|
||||
DomainRequest.DomainRequestStatus.ACTION_NEEDED,
|
||||
DomainRequest.DomainRequestStatus.REJECTED,
|
||||
DomainRequest.DomainRequestStatus.INELIGIBLE,
|
||||
]
|
||||
|
||||
# If a status change occured, check for validity
|
||||
if status != initial_status and status in checked_statuses:
|
||||
# Checks the "investigators" field for validity.
|
||||
# That field must obey certain conditions when an application is approved.
|
||||
# That field must obey certain conditions when an domain_request is approved.
|
||||
# Will call "add_error" if any issues are found.
|
||||
self._check_for_valid_investigator(investigator)
|
||||
|
||||
|
@ -1163,7 +1163,7 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
|||
|
||||
# == Handle non-status changes == #
|
||||
|
||||
# Get the original application from the database.
|
||||
# Get the original domain_request from the database.
|
||||
original_obj = models.DomainRequest.objects.get(pk=obj.pk)
|
||||
if obj.status == original_obj.status:
|
||||
# If the status hasn't changed, let the base function take care of it
|
||||
|
@ -1203,9 +1203,9 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
|||
should_proceed = False
|
||||
return should_proceed
|
||||
|
||||
application_is_not_approved = obj.status != models.DomainRequest.DomainRequestStatus.APPROVED
|
||||
if application_is_not_approved and not obj.domain_is_not_active():
|
||||
# If an admin tried to set an approved application to
|
||||
request_is_not_approved = obj.status != models.DomainRequest.DomainRequestStatus.APPROVED
|
||||
if request_is_not_approved and not obj.domain_is_not_active():
|
||||
# If an admin tried to set an approved domain_request to
|
||||
# another status and the related domain is already
|
||||
# active, shortcut the action and throw a friendly
|
||||
# error message. This action would still not go through
|
||||
|
@ -1248,7 +1248,7 @@ class DomainRequestAdmin(ListHeaderAdmin):
|
|||
return (obj, should_proceed)
|
||||
|
||||
def get_status_method_mapping(self, domain_request):
|
||||
"""Returns what method should be ran given an application object"""
|
||||
"""Returns what method should be ran given an DomainRequest object"""
|
||||
# Define a per-object mapping
|
||||
status_method_mapping = {
|
||||
models.DomainRequest.DomainRequestStatus.STARTED: None,
|
||||
|
|
|
@ -9,7 +9,7 @@ from django.db import models
|
|||
from django_fsm import FSMField, transition # type: ignore
|
||||
from django.utils import timezone
|
||||
from registrar.models.domain import Domain
|
||||
from registrar.utility.errors import FSMdomain_requestError, FSMErrorCodes
|
||||
from registrar.utility.errors import FSMApplicationError, FSMErrorCodes
|
||||
|
||||
from .utility.time_stamped_model import TimeStampedModel
|
||||
from ..utility.email import send_templated_email, EmailSendingError
|
||||
|
@ -19,7 +19,7 @@ logger = logging.getLogger(__name__)
|
|||
|
||||
|
||||
class DomainRequest(TimeStampedModel):
|
||||
"""A registrant's request for a new domain."""
|
||||
"""A registrant's domain request for a new domain."""
|
||||
|
||||
# Constants for choice fields
|
||||
class DomainRequestStatus(models.TextChoices):
|
||||
|
@ -116,7 +116,7 @@ class DomainRequest(TimeStampedModel):
|
|||
class OrganizationChoicesVerbose(models.TextChoices):
|
||||
"""
|
||||
Secondary organization choices
|
||||
For use in the domain_request form and on the templates
|
||||
For use in the domain request form and on the templates
|
||||
Keys need to match OrganizationChoices
|
||||
"""
|
||||
|
||||
|
@ -367,7 +367,7 @@ class DomainRequest(TimeStampedModel):
|
|||
NAMING_REQUIREMENTS = "naming_not_met", "Naming requirements not met"
|
||||
OTHER = "other", "Other/Unspecified"
|
||||
|
||||
# #### Internal fields about the domain_request #####
|
||||
# #### Internal fields about the domain request #####
|
||||
status = FSMField(
|
||||
choices=DomainRequestStatus.choices, # possible states as an array of constants
|
||||
default=DomainRequestStatus.STARTED, # sensible default
|
||||
|
@ -380,7 +380,7 @@ class DomainRequest(TimeStampedModel):
|
|||
blank=True,
|
||||
)
|
||||
|
||||
# This is the domain_request user who created this domain_request. The contact
|
||||
# This is the domain request user who created this domain request. The contact
|
||||
# information that they gave is in the `submitter` field
|
||||
creator = models.ForeignKey(
|
||||
"registrar.User",
|
||||
|
@ -500,7 +500,7 @@ class DomainRequest(TimeStampedModel):
|
|||
on_delete=models.PROTECT,
|
||||
)
|
||||
|
||||
# "+" means no reverse relation to lookup domain_requests from Website
|
||||
# "+" means no reverse relation to lookup domain requests from Website
|
||||
current_websites = models.ManyToManyField(
|
||||
"registrar.Website",
|
||||
blank=True,
|
||||
|
@ -513,7 +513,7 @@ class DomainRequest(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
help_text="The approved domain",
|
||||
related_name="domain_domain_request",
|
||||
related_name="domain_request",
|
||||
on_delete=models.SET_NULL,
|
||||
)
|
||||
|
||||
|
@ -522,7 +522,7 @@ class DomainRequest(TimeStampedModel):
|
|||
null=True,
|
||||
blank=True,
|
||||
help_text="The requested domain",
|
||||
related_name="domain_domain_request",
|
||||
related_name="domain_request",
|
||||
on_delete=models.PROTECT,
|
||||
)
|
||||
alternative_domains = models.ManyToManyField(
|
||||
|
@ -531,8 +531,8 @@ class DomainRequest(TimeStampedModel):
|
|||
related_name="alternatives+",
|
||||
)
|
||||
|
||||
# This is the contact information provided by the applicant. The
|
||||
# domain_request user who created it is in the `creator` field.
|
||||
# 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,
|
||||
|
@ -572,7 +572,7 @@ class DomainRequest(TimeStampedModel):
|
|||
help_text="Acknowledged .gov acceptable use policy",
|
||||
)
|
||||
|
||||
# submission date records when domain_request is submitted
|
||||
# submission date records when domain request is submitted
|
||||
submission_date = models.DateField(
|
||||
null=True,
|
||||
blank=True,
|
||||
|
@ -591,7 +591,7 @@ class DomainRequest(TimeStampedModel):
|
|||
if self.requested_domain and self.requested_domain.name:
|
||||
return self.requested_domain.name
|
||||
else:
|
||||
return f"{self.status} domain_request created by {self.creator}"
|
||||
return f"{self.status} domain request created by {self.creator}"
|
||||
except Exception:
|
||||
return ""
|
||||
|
||||
|
@ -665,7 +665,7 @@ class DomainRequest(TimeStampedModel):
|
|||
target=DomainRequestStatus.SUBMITTED,
|
||||
)
|
||||
def submit(self):
|
||||
"""Submit an domain_request that is started.
|
||||
"""Submit an domain request that is started.
|
||||
|
||||
As a side effect, an email notification is sent."""
|
||||
|
||||
|
@ -713,7 +713,7 @@ class DomainRequest(TimeStampedModel):
|
|||
conditions=[domain_is_not_active, investigator_exists_and_is_staff],
|
||||
)
|
||||
def in_review(self):
|
||||
"""Investigate an domain_request that has been submitted.
|
||||
"""Investigate an domain request that has been submitted.
|
||||
|
||||
This action is logged.
|
||||
|
||||
|
@ -745,7 +745,7 @@ class DomainRequest(TimeStampedModel):
|
|||
conditions=[domain_is_not_active, investigator_exists_and_is_staff],
|
||||
)
|
||||
def action_needed(self):
|
||||
"""Send back an domain_request that is under investigation or rejected.
|
||||
"""Send back an domain request that is under investigation or rejected.
|
||||
|
||||
This action is logged.
|
||||
|
||||
|
@ -783,7 +783,7 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
This has substantial side-effects because it creates another database
|
||||
object for the approved Domain and makes the user who created the
|
||||
domain_request into an admin on that domain. It also triggers an email
|
||||
domain request into an admin on that domain. It also triggers an email
|
||||
notification."""
|
||||
|
||||
# create the domain
|
||||
|
@ -791,7 +791,7 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
# == Check that the domain_request is valid == #
|
||||
if Domain.objects.filter(name=self.requested_domain.name).exists():
|
||||
raise FSMdomain_requestError(code=FSMErrorCodes.APPROVE_DOMAIN_IN_USE)
|
||||
raise FSMApplicationError(code=FSMErrorCodes.APPROVE_DOMAIN_IN_USE)
|
||||
|
||||
# == Create the domain and related components == #
|
||||
created_domain = Domain.objects.create(name=self.requested_domain.name)
|
||||
|
@ -799,7 +799,7 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
# copy the information from DomainRequest into domaininformation
|
||||
DomainInformation = apps.get_model("registrar.DomainInformation")
|
||||
DomainInformation.create_from_da(domain_domain_request=self, domain=created_domain)
|
||||
DomainInformation.create_from_da(domain_request=self, domain=created_domain)
|
||||
|
||||
# create the permission for the user
|
||||
UserDomainRole = apps.get_model("registrar.UserDomainRole")
|
||||
|
@ -812,7 +812,7 @@ class DomainRequest(TimeStampedModel):
|
|||
|
||||
# == Send out an email == #
|
||||
self._send_status_update_email(
|
||||
"domain_request approved",
|
||||
"domain request approved",
|
||||
"emails/status_change_approved.txt",
|
||||
"emails/status_change_approved_subject.txt",
|
||||
send_email,
|
||||
|
@ -824,7 +824,7 @@ class DomainRequest(TimeStampedModel):
|
|||
target=DomainRequestStatus.WITHDRAWN,
|
||||
)
|
||||
def withdraw(self):
|
||||
"""Withdraw an domain_request that has been submitted."""
|
||||
"""Withdraw an domain request that has been submitted."""
|
||||
|
||||
self._send_status_update_email(
|
||||
"withdraw",
|
||||
|
@ -839,7 +839,7 @@ class DomainRequest(TimeStampedModel):
|
|||
conditions=[domain_is_not_active, investigator_exists_and_is_staff],
|
||||
)
|
||||
def reject(self):
|
||||
"""Reject an domain_request that has been submitted.
|
||||
"""Reject an domain request that has been submitted.
|
||||
|
||||
As side effects this will delete the domain and domain_information
|
||||
(will cascade), and send an email notification."""
|
||||
|
@ -868,7 +868,7 @@ class DomainRequest(TimeStampedModel):
|
|||
"""The applicant is a bad actor, reject with prejudice.
|
||||
|
||||
No email As a side effect, but we block the applicant from editing
|
||||
any existing domains/domain_requests and from submitting new aplications.
|
||||
any existing domains/domain requests and from submitting new aplications.
|
||||
We do this by setting an ineligible status on the user, which the
|
||||
permissions classes test against. This will also delete the domain
|
||||
and domain_information (will cascade) when they exist."""
|
||||
|
@ -881,7 +881,7 @@ class DomainRequest(TimeStampedModel):
|
|||
# ## Form policies ###
|
||||
#
|
||||
# These methods control what questions need to be answered by applicants
|
||||
# during the domain_request flow. They are policies about the domain_request so
|
||||
# during the domain request flow. They are policies about the domain request so
|
||||
# they appear here.
|
||||
|
||||
def show_organization_federal(self) -> bool:
|
||||
|
@ -917,15 +917,15 @@ class DomainRequest(TimeStampedModel):
|
|||
]
|
||||
|
||||
def has_rationale(self) -> bool:
|
||||
"""Does this domain_request have no_other_contacts_rationale?"""
|
||||
"""Does this domain request have no_other_contacts_rationale?"""
|
||||
return bool(self.no_other_contacts_rationale)
|
||||
|
||||
def has_other_contacts(self) -> bool:
|
||||
"""Does this domain_request have other contacts listed?"""
|
||||
"""Does this domain request have other contacts listed?"""
|
||||
return self.other_contacts.exists()
|
||||
|
||||
def is_federal(self) -> Union[bool, None]:
|
||||
"""Is this domain_request for a federal agency?
|
||||
"""Is this domain request for a federal agency?
|
||||
|
||||
organization_type can be both null and blank,
|
||||
"""
|
||||
|
|
|
@ -599,11 +599,11 @@ def completed_domain_request(
|
|||
|
||||
return domain_request
|
||||
|
||||
def set_domain_request_investigators(application_list: list[DomainRequest], investigator_user: User):
|
||||
def set_domain_request_investigators(domain_request_list: list[DomainRequest], investigator_user: User):
|
||||
"""Helper method that sets the investigator field of all provided domain_requests"""
|
||||
for application in application_list:
|
||||
application.investigator = investigator_user
|
||||
application.save()
|
||||
for request in domain_request_list:
|
||||
request.investigator = investigator_user
|
||||
request.save()
|
||||
|
||||
|
||||
def multiple_unalphabetical_domain_objects(
|
||||
|
|
|
@ -52,8 +52,8 @@ class TestDomainRequest(TestCase):
|
|||
status=DomainRequest.DomainRequestStatus.INELIGIBLE, name="ineligible.gov"
|
||||
)
|
||||
|
||||
# Store all application statuses in a variable for ease of use
|
||||
self.all_applications = [
|
||||
# Store all domain request statuses in a variable for ease of use
|
||||
self.all_domain_requests = [
|
||||
self.started_domain_request,
|
||||
self.submitted_domain_request,
|
||||
self.in_review_domain_request,
|
||||
|
@ -269,7 +269,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_does_not_raise_error(test_cases, "submit")
|
||||
|
||||
|
@ -286,7 +286,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_domain_request_investigators(self.all_applications, user)
|
||||
set_domain_request_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_does_not_raise_error(test_cases, "submit")
|
||||
|
||||
|
@ -363,7 +363,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "in_review")
|
||||
|
||||
|
@ -382,7 +382,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_applications_investigators(self.all_applications, user)
|
||||
set_applications_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "in_review")
|
||||
|
||||
|
@ -424,7 +424,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "action_needed")
|
||||
|
||||
|
@ -442,7 +442,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_applications_investigators(self.all_applications, user)
|
||||
set_applications_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "action_needed")
|
||||
|
||||
|
@ -484,7 +484,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "approve")
|
||||
|
||||
|
@ -501,7 +501,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_applications_investigators(self.all_applications, user)
|
||||
set_applications_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "approve")
|
||||
|
||||
|
@ -555,7 +555,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_does_not_raise_error(test_cases, "withdraw")
|
||||
|
||||
|
@ -573,7 +573,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_applications_investigators(self.all_applications, user)
|
||||
set_applications_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_does_not_raise_error(test_cases, "withdraw")
|
||||
|
||||
|
@ -615,7 +615,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "reject")
|
||||
|
||||
|
@ -632,7 +632,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_applications_investigators(self.all_applications, user)
|
||||
set_applications_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "reject")
|
||||
|
||||
|
@ -676,7 +676,7 @@ class TestDomainRequest(TestCase):
|
|||
]
|
||||
|
||||
# Set all investigators to none
|
||||
set_domain_request_investigators(self.all_applications, None)
|
||||
set_domain_request_investigators(self.all_domain_requests, None)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "reject_with_prejudice")
|
||||
|
||||
|
@ -694,7 +694,7 @@ class TestDomainRequest(TestCase):
|
|||
|
||||
# Set all investigators to a user with no staff privs
|
||||
user, _ = User.objects.get_or_create(username="pancakesyrup", is_staff=False)
|
||||
set_applications_investigators(self.all_applications, user)
|
||||
set_applications_investigators(self.all_domain_requests, user)
|
||||
|
||||
self.assert_fsm_transition_raises_error(test_cases, "reject_with_prejudice")
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue