mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-31 06:56:33 +02:00
Fix bug with load senior official table
This commit is contained in:
parent
a9a93df5cd
commit
3837359977
2 changed files with 7 additions and 10 deletions
|
@ -35,7 +35,6 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
Note:
|
Note:
|
||||||
- If the row is missing SO data - it will not be added.
|
- If the row is missing SO data - it will not be added.
|
||||||
- Given we can add the row, any blank first_name will be replaced with "-".
|
|
||||||
""", # noqa: W291
|
""", # noqa: W291
|
||||||
prompt_title="Do you wish to load records into the SeniorOfficial table?",
|
prompt_title="Do you wish to load records into the SeniorOfficial table?",
|
||||||
)
|
)
|
||||||
|
@ -64,7 +63,11 @@ class Command(BaseCommand):
|
||||||
# Clean the returned data
|
# Clean the returned data
|
||||||
for key, value in so_kwargs.items():
|
for key, value in so_kwargs.items():
|
||||||
if isinstance(value, str):
|
if isinstance(value, str):
|
||||||
so_kwargs[key] = value.strip()
|
clean_string = value.strip()
|
||||||
|
if clean_string:
|
||||||
|
so_kwargs[key] = clean_string
|
||||||
|
else:
|
||||||
|
so_kwargs[key] = None
|
||||||
|
|
||||||
# Handle the federal_agency record seperately (db call)
|
# Handle the federal_agency record seperately (db call)
|
||||||
agency_name = row.get("Agency").strip() if row.get("Agency") else None
|
agency_name = row.get("Agency").strip() if row.get("Agency") else None
|
||||||
|
@ -95,17 +98,11 @@ class Command(BaseCommand):
|
||||||
def create_senior_official(self, so_kwargs):
|
def create_senior_official(self, so_kwargs):
|
||||||
"""Creates a senior official object from kwargs but does not add it to the DB"""
|
"""Creates a senior official object from kwargs but does not add it to the DB"""
|
||||||
|
|
||||||
# WORKAROUND: Placeholder value for first name,
|
|
||||||
# as not having these makes it impossible to access through DJA.
|
|
||||||
old_first_name = so_kwargs["first_name"]
|
|
||||||
if not so_kwargs["first_name"]:
|
|
||||||
so_kwargs["first_name"] = "-"
|
|
||||||
|
|
||||||
# Create a new SeniorOfficial object
|
# Create a new SeniorOfficial object
|
||||||
new_so = SeniorOfficial(**so_kwargs)
|
new_so = SeniorOfficial(**so_kwargs)
|
||||||
|
|
||||||
# Store a variable for the console logger
|
# Store a variable for the console logger
|
||||||
if all([old_first_name, new_so.last_name]):
|
if all([new_so.first_name, new_so.last_name]):
|
||||||
record_display = new_so
|
record_display = new_so
|
||||||
else:
|
else:
|
||||||
record_display = so_kwargs
|
record_display = so_kwargs
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue