mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-26 04:28:39 +02:00
Merge remote-tracking branch 'origin/main' into nl/1780-check-SES-before-adding-user
This commit is contained in:
commit
5a72db1d08
5 changed files with 31 additions and 6 deletions
|
@ -385,7 +385,6 @@ class DomainOrgNameAddressForm(forms.ModelForm):
|
||||||
# because for this fields we are creating an individual
|
# because for this fields we are creating an individual
|
||||||
# instance of the Select. For the other fields we use the for loop to set
|
# instance of the Select. For the other fields we use the for loop to set
|
||||||
# the class's required attribute to true.
|
# the class's required attribute to true.
|
||||||
"federal_agency": forms.TextInput,
|
|
||||||
"organization_name": forms.TextInput,
|
"organization_name": forms.TextInput,
|
||||||
"address_line1": forms.TextInput,
|
"address_line1": forms.TextInput,
|
||||||
"address_line2": forms.TextInput,
|
"address_line2": forms.TextInput,
|
||||||
|
|
|
@ -9,6 +9,7 @@ from django.db import models
|
||||||
from django_fsm import FSMField, transition # type: ignore
|
from django_fsm import FSMField, transition # type: ignore
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from registrar.models.domain import Domain
|
from registrar.models.domain import Domain
|
||||||
|
from registrar.models.federal_agency import FederalAgency
|
||||||
from registrar.models.utility.generic_helper import CreateOrUpdateOrganizationTypeHelper
|
from registrar.models.utility.generic_helper import CreateOrUpdateOrganizationTypeHelper
|
||||||
from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes
|
from registrar.utility.errors import FSMDomainRequestError, FSMErrorCodes
|
||||||
|
|
||||||
|
@ -751,6 +752,10 @@ class DomainRequest(TimeStampedModel):
|
||||||
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."""
|
notification."""
|
||||||
|
|
||||||
|
if self.federal_agency is None:
|
||||||
|
self.federal_agency = FederalAgency.objects.filter(agency="Non-Federal Agency").first()
|
||||||
|
self.save()
|
||||||
|
|
||||||
# create the domain
|
# create the domain
|
||||||
Domain = apps.get_model("registrar.Domain")
|
Domain = apps.get_model("registrar.Domain")
|
||||||
|
|
||||||
|
|
|
@ -646,7 +646,7 @@ class TestDomainAdmin(MockEppLib, WebTest):
|
||||||
response = self.client.get("/admin/registrar/domain/")
|
response = self.client.get("/admin/registrar/domain/")
|
||||||
# There are 4 template references to Federal (4) plus four references in the table
|
# There are 4 template references to Federal (4) plus four references in the table
|
||||||
# for our actual domain_request
|
# for our actual domain_request
|
||||||
self.assertContains(response, "Federal", count=54)
|
self.assertContains(response, "Federal", count=56)
|
||||||
# This may be a bit more robust
|
# This may be a bit more robust
|
||||||
self.assertContains(response, '<td class="field-generic_org_type">Federal</td>', count=1)
|
self.assertContains(response, '<td class="field-generic_org_type">Federal</td>', count=1)
|
||||||
# Now let's make sure the long description does not exist
|
# Now let's make sure the long description does not exist
|
||||||
|
|
|
@ -12,6 +12,7 @@ from registrar.models import (
|
||||||
DraftDomain,
|
DraftDomain,
|
||||||
DomainInvitation,
|
DomainInvitation,
|
||||||
UserDomainRole,
|
UserDomainRole,
|
||||||
|
FederalAgency,
|
||||||
)
|
)
|
||||||
|
|
||||||
import boto3_mocking
|
import boto3_mocking
|
||||||
|
@ -75,6 +76,26 @@ class TestDomainRequest(TestCase):
|
||||||
with less_console_noise():
|
with less_console_noise():
|
||||||
return self.assertRaises(Exception, None, exception_type)
|
return self.assertRaises(Exception, None, exception_type)
|
||||||
|
|
||||||
|
def test_federal_agency_set_to_non_federal_on_approve(self):
|
||||||
|
"""Ensures that when the federal_agency field is 'none' when .approve() is called,
|
||||||
|
the field is set to the 'Non-Federal Agency' record"""
|
||||||
|
domain_request = completed_domain_request(
|
||||||
|
status=DomainRequest.DomainRequestStatus.IN_REVIEW,
|
||||||
|
name="city2.gov",
|
||||||
|
federal_agency=None,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Ensure that the federal agency is None
|
||||||
|
self.assertEqual(domain_request.federal_agency, None)
|
||||||
|
|
||||||
|
# Approve the request
|
||||||
|
domain_request.approve()
|
||||||
|
self.assertEqual(domain_request.status, DomainRequest.DomainRequestStatus.APPROVED)
|
||||||
|
|
||||||
|
# After approval, it should be "Non-Federal agency"
|
||||||
|
expected_federal_agency = FederalAgency.objects.filter(agency="Non-Federal Agency").first()
|
||||||
|
self.assertEqual(domain_request.federal_agency, expected_federal_agency)
|
||||||
|
|
||||||
def test_empty_create_fails(self):
|
def test_empty_create_fails(self):
|
||||||
"""Can't create a completely empty domain request.
|
"""Can't create a completely empty domain request.
|
||||||
NOTE: something about theexception this test raises messes up with the
|
NOTE: something about theexception this test raises messes up with the
|
||||||
|
@ -942,6 +963,7 @@ class TestDomainInformation(TestCase):
|
||||||
domain=domain,
|
domain=domain,
|
||||||
notes="test notes",
|
notes="test notes",
|
||||||
domain_request=domain_request,
|
domain_request=domain_request,
|
||||||
|
federal_agency=FederalAgency.objects.get(agency="Non-Federal Agency"),
|
||||||
).__dict__
|
).__dict__
|
||||||
|
|
||||||
# Test the two records for consistency
|
# Test the two records for consistency
|
||||||
|
|
|
@ -1447,7 +1447,7 @@ class TestDomainOrganization(TestDomainOverview):
|
||||||
|
|
||||||
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
session_id = self.app.cookies[settings.SESSION_COOKIE_NAME]
|
||||||
|
|
||||||
org_name_page.form["federal_agency"] = "Department of State"
|
org_name_page.form["federal_agency"] = FederalAgency.objects.filter(agency="Department of State").get().id
|
||||||
org_name_page.form["city"] = "Faketown"
|
org_name_page.form["city"] = "Faketown"
|
||||||
|
|
||||||
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
self.app.set_cookie(settings.SESSION_COOKIE_NAME, session_id)
|
||||||
|
@ -1456,9 +1456,8 @@ class TestDomainOrganization(TestDomainOverview):
|
||||||
success_result_page = org_name_page.form.submit()
|
success_result_page = org_name_page.form.submit()
|
||||||
self.assertEqual(success_result_page.status_code, 200)
|
self.assertEqual(success_result_page.status_code, 200)
|
||||||
|
|
||||||
# Check for the old and new value
|
# Check that the agency has not changed
|
||||||
self.assertContains(success_result_page, federal_agency.id)
|
self.assertEqual(self.domain_information.federal_agency.agency, "AMTRAK")
|
||||||
self.assertNotContains(success_result_page, "Department of State")
|
|
||||||
|
|
||||||
# Do another check on the form itself
|
# Do another check on the form itself
|
||||||
form = success_result_page.forms[0]
|
form = success_result_page.forms[0]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue