mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 23:16:36 +02:00
Merge branch 'main' into nl/3275-slowness-admin-tables
This commit is contained in:
commit
b8dc433e24
4 changed files with 74 additions and 13 deletions
|
@ -578,6 +578,13 @@ class MockDb(TestCase):
|
||||||
creator=cls.custom_superuser, federal_agency=cls.federal_agency_3, organization_type="federal"
|
creator=cls.custom_superuser, federal_agency=cls.federal_agency_3, organization_type="federal"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cls.suborganization_1, _ = Suborganization.objects.get_or_create(
|
||||||
|
name="SubOrg 1",
|
||||||
|
portfolio=cls.portfolio_1,
|
||||||
|
city="Nashville",
|
||||||
|
state_territory="TN",
|
||||||
|
)
|
||||||
|
|
||||||
current_date = get_time_aware_date(datetime(2024, 4, 2))
|
current_date = get_time_aware_date(datetime(2024, 4, 2))
|
||||||
# Create start and end dates using timedelta
|
# Create start and end dates using timedelta
|
||||||
|
|
||||||
|
@ -848,6 +855,7 @@ class MockDb(TestCase):
|
||||||
status=DomainRequest.DomainRequestStatus.IN_REVIEW,
|
status=DomainRequest.DomainRequestStatus.IN_REVIEW,
|
||||||
name="city2.gov",
|
name="city2.gov",
|
||||||
portfolio=cls.portfolio_1,
|
portfolio=cls.portfolio_1,
|
||||||
|
sub_organization=cls.suborganization_1,
|
||||||
)
|
)
|
||||||
cls.domain_request_3 = completed_domain_request(
|
cls.domain_request_3 = completed_domain_request(
|
||||||
status=DomainRequest.DomainRequestStatus.STARTED,
|
status=DomainRequest.DomainRequestStatus.STARTED,
|
||||||
|
@ -863,6 +871,9 @@ class MockDb(TestCase):
|
||||||
cls.domain_request_5 = completed_domain_request(
|
cls.domain_request_5 = completed_domain_request(
|
||||||
status=DomainRequest.DomainRequestStatus.APPROVED,
|
status=DomainRequest.DomainRequestStatus.APPROVED,
|
||||||
name="city5.gov",
|
name="city5.gov",
|
||||||
|
requested_suborganization="requested_suborg",
|
||||||
|
suborganization_city="SanFran",
|
||||||
|
suborganization_state_territory="CA",
|
||||||
)
|
)
|
||||||
cls.domain_request_6 = completed_domain_request(
|
cls.domain_request_6 = completed_domain_request(
|
||||||
status=DomainRequest.DomainRequestStatus.STARTED,
|
status=DomainRequest.DomainRequestStatus.STARTED,
|
||||||
|
|
|
@ -2101,6 +2101,10 @@ class TestPatchSuborganizations(MockDbForIndividualTests):
|
||||||
1. Fewest spaces
|
1. Fewest spaces
|
||||||
2. Most leading capitals
|
2. Most leading capitals
|
||||||
"""
|
"""
|
||||||
|
# Delete any other suborganizations defined in the initial test dataset
|
||||||
|
DomainRequest.objects.all().delete()
|
||||||
|
Suborganization.objects.all().delete()
|
||||||
|
|
||||||
Suborganization.objects.create(name="Test Organization ", portfolio=self.portfolio_1)
|
Suborganization.objects.create(name="Test Organization ", portfolio=self.portfolio_1)
|
||||||
Suborganization.objects.create(name="test organization", portfolio=self.portfolio_1)
|
Suborganization.objects.create(name="test organization", portfolio=self.portfolio_1)
|
||||||
Suborganization.objects.create(name="Test Organization", portfolio=self.portfolio_1)
|
Suborganization.objects.create(name="Test Organization", portfolio=self.portfolio_1)
|
||||||
|
@ -2114,6 +2118,10 @@ class TestPatchSuborganizations(MockDbForIndividualTests):
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
def test_hardcoded_record(self):
|
def test_hardcoded_record(self):
|
||||||
"""Tests that our hardcoded records update as we expect them to"""
|
"""Tests that our hardcoded records update as we expect them to"""
|
||||||
|
# Delete any other suborganizations defined in the initial test dataset
|
||||||
|
DomainRequest.objects.all().delete()
|
||||||
|
Suborganization.objects.all().delete()
|
||||||
|
|
||||||
# Create orgs with old and new name formats
|
# Create orgs with old and new name formats
|
||||||
old_name = "USDA/OC"
|
old_name = "USDA/OC"
|
||||||
new_name = "USDA, Office of Communications"
|
new_name = "USDA, Office of Communications"
|
||||||
|
@ -2123,7 +2131,7 @@ class TestPatchSuborganizations(MockDbForIndividualTests):
|
||||||
|
|
||||||
self.run_patch_suborganizations()
|
self.run_patch_suborganizations()
|
||||||
|
|
||||||
# Verify only the new one remains
|
# Verify only the new one of the two remains
|
||||||
self.assertEqual(Suborganization.objects.count(), 1)
|
self.assertEqual(Suborganization.objects.count(), 1)
|
||||||
remaining = Suborganization.objects.first()
|
remaining = Suborganization.objects.first()
|
||||||
self.assertEqual(remaining.name, new_name)
|
self.assertEqual(remaining.name, new_name)
|
||||||
|
|
|
@ -729,6 +729,7 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
# "Submitted at",
|
# "Submitted at",
|
||||||
"Status",
|
"Status",
|
||||||
"Domain type",
|
"Domain type",
|
||||||
|
"Portfolio",
|
||||||
"Federal type",
|
"Federal type",
|
||||||
"Federal agency",
|
"Federal agency",
|
||||||
"Organization name",
|
"Organization name",
|
||||||
|
@ -736,6 +737,10 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
"City",
|
"City",
|
||||||
"State/territory",
|
"State/territory",
|
||||||
"Region",
|
"Region",
|
||||||
|
"Suborganization",
|
||||||
|
"Requested suborg",
|
||||||
|
"Suborg city",
|
||||||
|
"Suborg state/territory",
|
||||||
"Creator first name",
|
"Creator first name",
|
||||||
"Creator last name",
|
"Creator last name",
|
||||||
"Creator email",
|
"Creator email",
|
||||||
|
@ -765,28 +770,30 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
|
|
||||||
expected_content = (
|
expected_content = (
|
||||||
# Header
|
# Header
|
||||||
"Domain request,Status,Domain type,Federal type,Federal agency,Organization name,Election office,"
|
"Domain request,Status,Domain type,Portfolio,Federal type,Federal agency,Organization name,"
|
||||||
"City,State/territory,Region,Creator first name,Creator last name,Creator email,"
|
"Election office,City,State/territory,Region,Suborganization,Requested suborg,Suborg city,"
|
||||||
|
"Suborg state/territory,Creator first name,Creator last name,Creator email,"
|
||||||
"Creator approved domains count,Creator active requests count,Alternative domains,SO first name,"
|
"Creator approved domains count,Creator active requests count,Alternative domains,SO first name,"
|
||||||
"SO last name,SO email,SO title/role,Request purpose,Request additional details,Other contacts,"
|
"SO last name,SO email,SO title/role,Request purpose,Request additional details,Other contacts,"
|
||||||
"CISA regional representative,Current websites,Investigator\n"
|
"CISA regional representative,Current websites,Investigator\n"
|
||||||
# Content
|
# Content
|
||||||
"city5.gov,Approved,Federal,Executive,,Testorg,N/A,,NY,2,,,,1,0,city1.gov,Testy,Tester,testy@town.com,"
|
"city5.gov,Approved,Federal,No,Executive,,Testorg,N/A,,NY,2,requested_suborg,SanFran,CA,,,,,1,0,"
|
||||||
"Chief Tester,Purpose of the site,There is more,Testy Tester testy2@town.com,,city.com,\n"
|
"city1.gov,Testy,Tester,testy@town.com,Chief Tester,Purpose of the site,There is more,"
|
||||||
"city2.gov,In review,Federal,Executive,Portfolio 1 Federal Agency,,N/A,,NY,2,,,,0,1,city1.gov,,,,,"
|
"Testy Tester testy2@town.com,,city.com,\n"
|
||||||
"Purpose of the site,There is more,Testy Tester testy2@town.com,,city.com,\n"
|
"city2.gov,In review,Federal,Yes,Executive,Portfolio 1 Federal Agency,,N/A,,,2,SubOrg 1,,,,,,,0,"
|
||||||
"city3.gov,Submitted,Federal,Executive,Portfolio 1 Federal Agency,,N/A,,NY,2,,,,0,1,"
|
"1,city1.gov,,,,,Purpose of the site,There is more,Testy Tester testy2@town.com,,city.com,\n"
|
||||||
|
"city3.gov,Submitted,Federal,Yes,Executive,Portfolio 1 Federal Agency,,N/A,,,2,,,,,,,,0,1,"
|
||||||
'"cheeseville.gov, city1.gov, igorville.gov",,,,,Purpose of the site,CISA-first-name CISA-last-name | '
|
'"cheeseville.gov, city1.gov, igorville.gov",,,,,Purpose of the site,CISA-first-name CISA-last-name | '
|
||||||
'There is more,"Meow Tester24 te2@town.com, Testy1232 Tester24 te2@town.com, '
|
'There is more,"Meow Tester24 te2@town.com, Testy1232 Tester24 te2@town.com, '
|
||||||
'Testy Tester testy2@town.com",'
|
'Testy Tester testy2@town.com",'
|
||||||
'test@igorville.com,"city.com, https://www.example2.com, https://www.example.com",\n'
|
'test@igorville.com,"city.com, https://www.example2.com, https://www.example.com",\n'
|
||||||
"city4.gov,Submitted,City,Executive,,Testorg,Yes,,NY,2,,,,0,1,city1.gov,Testy,"
|
"city4.gov,Submitted,City,No,Executive,,Testorg,Yes,,NY,2,,,,,,,,0,1,city1.gov,Testy,"
|
||||||
"Tester,testy@town.com,"
|
"Tester,testy@town.com,"
|
||||||
"Chief Tester,Purpose of the site,CISA-first-name CISA-last-name | There is more,"
|
"Chief Tester,Purpose of the site,CISA-first-name CISA-last-name | There is more,"
|
||||||
"Testy Tester testy2@town.com,"
|
"Testy Tester testy2@town.com,"
|
||||||
"cisaRep@igorville.gov,city.com,\n"
|
"cisaRep@igorville.gov,city.com,\n"
|
||||||
"city6.gov,Submitted,Federal,Executive,Portfolio 1 Federal Agency,,N/A,,NY,2,,,,0,1,city1.gov,,,,,"
|
"city6.gov,Submitted,Federal,Yes,Executive,Portfolio 1 Federal Agency,,N/A,,,2,,,,,,,,0,1,city1.gov,"
|
||||||
"Purpose of the site,CISA-first-name CISA-last-name | There is more,Testy Tester testy2@town.com,"
|
",,,,Purpose of the site,CISA-first-name CISA-last-name | There is more,Testy Tester testy2@town.com,"
|
||||||
"cisaRep@igorville.gov,city.com,\n"
|
"cisaRep@igorville.gov,city.com,\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1660,6 +1660,27 @@ class DomainRequestExport(BaseExport):
|
||||||
default=F("organization_name"),
|
default=F("organization_name"),
|
||||||
output_field=CharField(),
|
output_field=CharField(),
|
||||||
),
|
),
|
||||||
|
"converted_city": Case(
|
||||||
|
# When portfolio is present, use its value instead
|
||||||
|
When(portfolio__isnull=False, then=F("portfolio__city")),
|
||||||
|
# Otherwise, return the natively assigned value
|
||||||
|
default=F("city"),
|
||||||
|
output_field=CharField(),
|
||||||
|
),
|
||||||
|
"converted_state_territory": Case(
|
||||||
|
# When portfolio is present, use its value instead
|
||||||
|
When(portfolio__isnull=False, then=F("portfolio__state_territory")),
|
||||||
|
# Otherwise, return the natively assigned value
|
||||||
|
default=F("state_territory"),
|
||||||
|
output_field=CharField(),
|
||||||
|
),
|
||||||
|
"converted_suborganization_name": Case(
|
||||||
|
# When sub_organization is present, use its name
|
||||||
|
When(sub_organization__isnull=False, then=F("sub_organization__name")),
|
||||||
|
# Otherwise, return empty string
|
||||||
|
default=Value(""),
|
||||||
|
output_field=CharField(),
|
||||||
|
),
|
||||||
"converted_so_email": Case(
|
"converted_so_email": Case(
|
||||||
# When portfolio is present, use its value instead
|
# When portfolio is present, use its value instead
|
||||||
When(portfolio__isnull=False, then=F("portfolio__senior_official__email")),
|
When(portfolio__isnull=False, then=F("portfolio__senior_official__email")),
|
||||||
|
@ -1786,6 +1807,10 @@ class DomainRequestExport(BaseExport):
|
||||||
status = model.get("status")
|
status = model.get("status")
|
||||||
status_display = DomainRequest.DomainRequestStatus.get_status_label(status) if status else None
|
status_display = DomainRequest.DomainRequestStatus.get_status_label(status) if status else None
|
||||||
|
|
||||||
|
# Handle the portfolio field. Display as a Yes/No
|
||||||
|
portfolio = model.get("portfolio")
|
||||||
|
portfolio_display = "Yes" if portfolio is not None else "No"
|
||||||
|
|
||||||
# Handle the region field.
|
# Handle the region field.
|
||||||
state_territory = model.get("state_territory")
|
state_territory = model.get("state_territory")
|
||||||
region = get_region(state_territory) if state_territory else None
|
region = get_region(state_territory) if state_territory else None
|
||||||
|
@ -1819,6 +1844,7 @@ class DomainRequestExport(BaseExport):
|
||||||
"Election office": human_readable_election_board,
|
"Election office": human_readable_election_board,
|
||||||
"Federal type": human_readable_federal_type,
|
"Federal type": human_readable_federal_type,
|
||||||
"Domain type": human_readable_org_type,
|
"Domain type": human_readable_org_type,
|
||||||
|
"Portfolio": portfolio_display,
|
||||||
"Request additional details": additional_details,
|
"Request additional details": additional_details,
|
||||||
# Annotated fields - passed into the request dict.
|
# Annotated fields - passed into the request dict.
|
||||||
"Creator approved domains count": model.get("creator_approved_domains_count", 0),
|
"Creator approved domains count": model.get("creator_approved_domains_count", 0),
|
||||||
|
@ -1827,6 +1853,10 @@ class DomainRequestExport(BaseExport):
|
||||||
"Other contacts": model.get("all_other_contacts"),
|
"Other contacts": model.get("all_other_contacts"),
|
||||||
"Current websites": model.get("all_current_websites"),
|
"Current websites": model.get("all_current_websites"),
|
||||||
# Untouched FK fields - passed into the request dict.
|
# Untouched FK fields - passed into the request dict.
|
||||||
|
"Suborganization": model.get("converted_suborganization_name"),
|
||||||
|
"Requested suborg": model.get("requested_suborganization"),
|
||||||
|
"Suborg city": model.get("suborganization_city"),
|
||||||
|
"Suborg state/territory": model.get("suborganization_state_territory"),
|
||||||
"Federal agency": model.get("converted_federal_agency"),
|
"Federal agency": model.get("converted_federal_agency"),
|
||||||
"SO first name": model.get("converted_senior_official_first_name"),
|
"SO first name": model.get("converted_senior_official_first_name"),
|
||||||
"SO last name": model.get("converted_senior_official_last_name"),
|
"SO last name": model.get("converted_senior_official_last_name"),
|
||||||
|
@ -1838,8 +1868,8 @@ class DomainRequestExport(BaseExport):
|
||||||
"Investigator": model.get("investigator__email"),
|
"Investigator": model.get("investigator__email"),
|
||||||
# Untouched fields
|
# Untouched fields
|
||||||
"Organization name": model.get("converted_organization_name"),
|
"Organization name": model.get("converted_organization_name"),
|
||||||
"City": model.get("city"),
|
"City": model.get("converted_city"),
|
||||||
"State/territory": model.get("state_territory"),
|
"State/territory": model.get("converted_state_territory"),
|
||||||
"Request purpose": model.get("purpose"),
|
"Request purpose": model.get("purpose"),
|
||||||
"CISA regional representative": model.get("cisa_representative_email"),
|
"CISA regional representative": model.get("cisa_representative_email"),
|
||||||
"Last submitted date": model.get("last_submitted_date"),
|
"Last submitted date": model.get("last_submitted_date"),
|
||||||
|
@ -2006,6 +2036,7 @@ class DomainRequestDataFull(DomainRequestExport):
|
||||||
"Last status update",
|
"Last status update",
|
||||||
"Status",
|
"Status",
|
||||||
"Domain type",
|
"Domain type",
|
||||||
|
"Portfolio",
|
||||||
"Federal type",
|
"Federal type",
|
||||||
"Federal agency",
|
"Federal agency",
|
||||||
"Organization name",
|
"Organization name",
|
||||||
|
@ -2013,6 +2044,10 @@ class DomainRequestDataFull(DomainRequestExport):
|
||||||
"City",
|
"City",
|
||||||
"State/territory",
|
"State/territory",
|
||||||
"Region",
|
"Region",
|
||||||
|
"Suborganization",
|
||||||
|
"Requested suborg",
|
||||||
|
"Suborg city",
|
||||||
|
"Suborg state/territory",
|
||||||
"Creator first name",
|
"Creator first name",
|
||||||
"Creator last name",
|
"Creator last name",
|
||||||
"Creator email",
|
"Creator email",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue