mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 10:16:13 +02:00
Merge pull request #3243 from cisagov/za/csv-export-hotfix
HOTFIX: #3242 - Revert @property changes in csv_export for current_full.csv and current_federal.csv
This commit is contained in:
commit
ecac2c294c
2 changed files with 108 additions and 27 deletions
|
@ -71,8 +71,8 @@ class CsvReportsTest(MockDbForSharedTests):
|
||||||
fake_open = mock_open()
|
fake_open = mock_open()
|
||||||
expected_file_content = [
|
expected_file_content = [
|
||||||
call("Domain name,Domain type,Agency,Organization name,City,State,Security contact email\r\n"),
|
call("Domain name,Domain type,Agency,Organization name,City,State,Security contact email\r\n"),
|
||||||
call("cdomain1.gov,Federal - Executive,Portfolio 1 Federal Agency,,,,(blank)\r\n"),
|
|
||||||
call("cdomain11.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\r\n"),
|
call("cdomain11.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\r\n"),
|
||||||
|
call("cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\r\n"),
|
||||||
call("adomain10.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
call("adomain10.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
||||||
call("ddomain3.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
call("ddomain3.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
||||||
]
|
]
|
||||||
|
@ -93,8 +93,8 @@ class CsvReportsTest(MockDbForSharedTests):
|
||||||
fake_open = mock_open()
|
fake_open = mock_open()
|
||||||
expected_file_content = [
|
expected_file_content = [
|
||||||
call("Domain name,Domain type,Agency,Organization name,City,State,Security contact email\r\n"),
|
call("Domain name,Domain type,Agency,Organization name,City,State,Security contact email\r\n"),
|
||||||
call("cdomain1.gov,Federal - Executive,Portfolio 1 Federal Agency,,,,(blank)\r\n"),
|
|
||||||
call("cdomain11.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\r\n"),
|
call("cdomain11.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\r\n"),
|
||||||
|
call("cdomain1.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\r\n"),
|
||||||
call("adomain10.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
call("adomain10.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
||||||
call("ddomain3.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
call("ddomain3.gov,Federal,Armed Forces Retirement Home,,,,(blank)\r\n"),
|
||||||
call("zdomain12.gov,Interstate,,,,,(blank)\r\n"),
|
call("zdomain12.gov,Interstate,,,,,(blank)\r\n"),
|
||||||
|
@ -493,17 +493,17 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
# sorted alphabetially by domain name
|
# sorted alphabetially by domain name
|
||||||
expected_content = (
|
expected_content = (
|
||||||
"Domain name,Domain type,Agency,Organization name,City,State,Security contact email\n"
|
"Domain name,Domain type,Agency,Organization name,City,State,Security contact email\n"
|
||||||
"defaultsecurity.gov,Federal - Executive,Portfolio1FederalAgency,,,,(blank)\n"
|
"cdomain11.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\n"
|
||||||
"cdomain11.gov,Federal - Executive,WorldWarICentennialCommission,,,,(blank)\n"
|
"defaultsecurity.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\n"
|
||||||
"adomain10.gov,Federal,ArmedForcesRetirementHome,,,,(blank)\n"
|
"adomain10.gov,Federal,Armed Forces Retirement Home,,,,(blank)\n"
|
||||||
"ddomain3.gov,Federal,ArmedForcesRetirementHome,,,,security@mail.gov\n"
|
"ddomain3.gov,Federal,Armed Forces Retirement Home,,,,security@mail.gov\n"
|
||||||
"zdomain12.gov,Interstate,,,,,(blank)\n"
|
"zdomain12.gov,Interstate,,,,,(blank)\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize line endings and remove commas,
|
# Normalize line endings and remove commas,
|
||||||
# spaces and leading/trailing whitespace
|
# spaces and leading/trailing whitespace
|
||||||
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip()
|
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip()
|
||||||
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip()
|
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip()
|
||||||
|
self.maxDiff = None
|
||||||
self.assertEqual(csv_content, expected_content)
|
self.assertEqual(csv_content, expected_content)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
@ -533,16 +533,16 @@ class ExportDataTest(MockDbForIndividualTests, MockEppLib):
|
||||||
# sorted alphabetially by domain name
|
# sorted alphabetially by domain name
|
||||||
expected_content = (
|
expected_content = (
|
||||||
"Domain name,Domain type,Agency,Organization name,City,State,Security contact email\n"
|
"Domain name,Domain type,Agency,Organization name,City,State,Security contact email\n"
|
||||||
"defaultsecurity.gov,Federal - Executive,Portfolio1FederalAgency,,,,(blank)\n"
|
"cdomain11.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\n"
|
||||||
"cdomain11.gov,Federal - Executive,WorldWarICentennialCommission,,,,(blank)\n"
|
"defaultsecurity.gov,Federal - Executive,World War I Centennial Commission,,,,(blank)\n"
|
||||||
"adomain10.gov,Federal,ArmedForcesRetirementHome,,,,(blank)\n"
|
"adomain10.gov,Federal,Armed Forces Retirement Home,,,,(blank)\n"
|
||||||
"ddomain3.gov,Federal,ArmedForcesRetirementHome,,,,security@mail.gov\n"
|
"ddomain3.gov,Federal,Armed Forces Retirement Home,,,,security@mail.gov\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Normalize line endings and remove commas,
|
# Normalize line endings and remove commas,
|
||||||
# spaces and leading/trailing whitespace
|
# spaces and leading/trailing whitespace
|
||||||
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip()
|
csv_content = csv_content.replace(",,", "").replace(",", "").replace(" ", "").replace("\r\n", "\n").strip()
|
||||||
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip()
|
expected_content = expected_content.replace(",,", "").replace(",", "").replace(" ", "").strip()
|
||||||
|
self.maxDiff = None
|
||||||
self.assertEqual(csv_content, expected_content)
|
self.assertEqual(csv_content, expected_content)
|
||||||
|
|
||||||
@less_console_noise_decorator
|
@less_console_noise_decorator
|
||||||
|
|
|
@ -744,30 +744,45 @@ class DomainExport(BaseExport):
|
||||||
):
|
):
|
||||||
security_contact_email = "(blank)"
|
security_contact_email = "(blank)"
|
||||||
|
|
||||||
|
model["status"] = human_readable_status
|
||||||
|
model["first_ready_on"] = first_ready_on
|
||||||
|
model["expiration_date"] = expiration_date
|
||||||
|
model["domain_type"] = domain_type
|
||||||
|
model["security_contact_email"] = security_contact_email
|
||||||
# create a dictionary of fields which can be included in output.
|
# create a dictionary of fields which can be included in output.
|
||||||
# "extra_fields" are precomputed fields (generated in the DB or parsed).
|
# "extra_fields" are precomputed fields (generated in the DB or parsed).
|
||||||
|
FIELDS = cls.get_fields(model)
|
||||||
|
|
||||||
|
row = [FIELDS.get(column, "") for column in columns]
|
||||||
|
|
||||||
|
return row
|
||||||
|
|
||||||
|
# NOTE - this override is temporary.
|
||||||
|
# We are running into a problem where DomainDataFull and DomainDataFederal are
|
||||||
|
# pulling the wrong data.
|
||||||
|
# For example, the portfolio name, rather than the suborganization name.
|
||||||
|
# This can be removed after that gets fixed.
|
||||||
|
@classmethod
|
||||||
|
def get_fields(cls, model):
|
||||||
FIELDS = {
|
FIELDS = {
|
||||||
"Domain name": model.get("domain__name"),
|
"Domain name": model.get("domain__name"),
|
||||||
"Status": human_readable_status,
|
"Status": model.get("status"),
|
||||||
"First ready on": first_ready_on,
|
"First ready on": model.get("first_ready_on"),
|
||||||
"Expiration date": expiration_date,
|
"Expiration date": model.get("expiration_date"),
|
||||||
"Domain type": domain_type,
|
"Domain type": model.get("domain_type"),
|
||||||
"Agency": model.get("converted_federal_agency"),
|
"Agency": model.get("converted_federal_agency"),
|
||||||
"Organization name": model.get("converted_organization_name"),
|
"Organization name": model.get("converted_organization_name"),
|
||||||
"City": model.get("converted_city"),
|
"City": model.get("converted_city"),
|
||||||
"State": model.get("converted_state_territory"),
|
"State": model.get("converted_state_territory"),
|
||||||
"SO": model.get("converted_so_name"),
|
"SO": model.get("converted_so_name"),
|
||||||
"SO email": model.get("converted_so_email"),
|
"SO email": model.get("converted_so_email"),
|
||||||
"Security contact email": security_contact_email,
|
"Security contact email": model.get("security_contact_email"),
|
||||||
"Created at": model.get("domain__created_at"),
|
"Created at": model.get("domain__created_at"),
|
||||||
"Deleted": model.get("domain__deleted"),
|
"Deleted": model.get("domain__deleted"),
|
||||||
"Domain managers": model.get("managers"),
|
"Domain managers": model.get("managers"),
|
||||||
"Invited domain managers": model.get("invited_users"),
|
"Invited domain managers": model.get("invited_users"),
|
||||||
}
|
}
|
||||||
|
return FIELDS
|
||||||
row = [FIELDS.get(column, "") for column in columns]
|
|
||||||
|
|
||||||
return row
|
|
||||||
|
|
||||||
def get_filtered_domain_infos_by_org(domain_infos_to_filter, org_to_filter_by):
|
def get_filtered_domain_infos_by_org(domain_infos_to_filter, org_to_filter_by):
|
||||||
"""Returns a list of Domain Requests that has been filtered by the given organization value."""
|
"""Returns a list of Domain Requests that has been filtered by the given organization value."""
|
||||||
|
@ -1077,6 +1092,39 @@ class DomainDataFull(DomainExport):
|
||||||
Inherits from BaseExport -> DomainExport
|
Inherits from BaseExport -> DomainExport
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# NOTE - this override is temporary.
|
||||||
|
# We are running into a problem where DomainDataFull is
|
||||||
|
# pulling the wrong data.
|
||||||
|
# For example, the portfolio name, rather than the suborganization name.
|
||||||
|
# This can be removed after that gets fixed.
|
||||||
|
# The following fields are changed from DomainExport:
|
||||||
|
# converted_organization_name => organization_name
|
||||||
|
# converted_city => city
|
||||||
|
# converted_state_territory => state_territory
|
||||||
|
# converted_so_name => so_name
|
||||||
|
# converted_so_email => senior_official__email
|
||||||
|
@classmethod
|
||||||
|
def get_fields(cls, model):
|
||||||
|
FIELDS = {
|
||||||
|
"Domain name": model.get("domain__name"),
|
||||||
|
"Status": model.get("status"),
|
||||||
|
"First ready on": model.get("first_ready_on"),
|
||||||
|
"Expiration date": model.get("expiration_date"),
|
||||||
|
"Domain type": model.get("domain_type"),
|
||||||
|
"Agency": model.get("federal_agency__agency"),
|
||||||
|
"Organization name": model.get("organization_name"),
|
||||||
|
"City": model.get("city"),
|
||||||
|
"State": model.get("state_territory"),
|
||||||
|
"SO": model.get("so_name"),
|
||||||
|
"SO email": model.get("senior_official__email"),
|
||||||
|
"Security contact email": model.get("security_contact_email"),
|
||||||
|
"Created at": model.get("domain__created_at"),
|
||||||
|
"Deleted": model.get("domain__deleted"),
|
||||||
|
"Domain managers": model.get("managers"),
|
||||||
|
"Invited domain managers": model.get("invited_users"),
|
||||||
|
}
|
||||||
|
return FIELDS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_columns(cls):
|
def get_columns(cls):
|
||||||
"""
|
"""
|
||||||
|
@ -1106,9 +1154,9 @@ class DomainDataFull(DomainExport):
|
||||||
"""
|
"""
|
||||||
# Coalesce is used to replace federal_type of None with ZZZZZ
|
# Coalesce is used to replace federal_type of None with ZZZZZ
|
||||||
return [
|
return [
|
||||||
"converted_generic_org_type",
|
"organization_type",
|
||||||
Coalesce("converted_federal_type", Value("ZZZZZ")),
|
Coalesce("federal_type", Value("ZZZZZ")),
|
||||||
"converted_federal_agency",
|
"federal_agency",
|
||||||
"domain__name",
|
"domain__name",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1164,6 +1212,39 @@ class DomainDataFederal(DomainExport):
|
||||||
Inherits from BaseExport -> DomainExport
|
Inherits from BaseExport -> DomainExport
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
# NOTE - this override is temporary.
|
||||||
|
# We are running into a problem where DomainDataFull is
|
||||||
|
# pulling the wrong data.
|
||||||
|
# For example, the portfolio name, rather than the suborganization name.
|
||||||
|
# This can be removed after that gets fixed.
|
||||||
|
# The following fields are changed from DomainExport:
|
||||||
|
# converted_organization_name => organization_name
|
||||||
|
# converted_city => city
|
||||||
|
# converted_state_territory => state_territory
|
||||||
|
# converted_so_name => so_name
|
||||||
|
# converted_so_email => senior_official__email
|
||||||
|
@classmethod
|
||||||
|
def get_fields(cls, model):
|
||||||
|
FIELDS = {
|
||||||
|
"Domain name": model.get("domain__name"),
|
||||||
|
"Status": model.get("status"),
|
||||||
|
"First ready on": model.get("first_ready_on"),
|
||||||
|
"Expiration date": model.get("expiration_date"),
|
||||||
|
"Domain type": model.get("domain_type"),
|
||||||
|
"Agency": model.get("federal_agency__agency"),
|
||||||
|
"Organization name": model.get("organization_name"),
|
||||||
|
"City": model.get("city"),
|
||||||
|
"State": model.get("state_territory"),
|
||||||
|
"SO": model.get("so_name"),
|
||||||
|
"SO email": model.get("senior_official__email"),
|
||||||
|
"Security contact email": model.get("security_contact_email"),
|
||||||
|
"Created at": model.get("domain__created_at"),
|
||||||
|
"Deleted": model.get("domain__deleted"),
|
||||||
|
"Domain managers": model.get("managers"),
|
||||||
|
"Invited domain managers": model.get("invited_users"),
|
||||||
|
}
|
||||||
|
return FIELDS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_columns(cls):
|
def get_columns(cls):
|
||||||
"""
|
"""
|
||||||
|
@ -1193,9 +1274,9 @@ class DomainDataFederal(DomainExport):
|
||||||
"""
|
"""
|
||||||
# Coalesce is used to replace federal_type of None with ZZZZZ
|
# Coalesce is used to replace federal_type of None with ZZZZZ
|
||||||
return [
|
return [
|
||||||
"converted_generic_org_type",
|
"organization_type",
|
||||||
Coalesce("converted_federal_type", Value("ZZZZZ")),
|
Coalesce("federal_type", Value("ZZZZZ")),
|
||||||
"converted_federal_agency",
|
"federal_agency",
|
||||||
"domain__name",
|
"domain__name",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue