mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-25 20:18:38 +02:00
Increase code clarity
This commit is contained in:
parent
68f75ec8a8
commit
57d4234544
1 changed files with 15 additions and 13 deletions
|
@ -61,25 +61,27 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
for di in domain_info_to_fix:
|
for di in domain_info_to_fix:
|
||||||
domain_name = di.domain.name
|
domain_name = di.domain.name
|
||||||
if domain_name in td_dict and td_dict.get(domain_name) is not None:
|
federal_agency = td_dict.get(domain_name)
|
||||||
# Grab existing federal_agency data
|
|
||||||
di.federal_agency = td_dict.get(domain_name)
|
# If agency exists on a TransitionDomain, update the related DomainInformation object
|
||||||
# Append it to our update list
|
if domain_name in td_dict and federal_agency is not None:
|
||||||
|
di.federal_agency = federal_agency
|
||||||
self.di_to_update.append(di)
|
self.di_to_update.append(di)
|
||||||
if debug:
|
log_message = f"{TerminalColors.OKCYAN}Updated {di}{TerminalColors.ENDC}"
|
||||||
logger.info(
|
|
||||||
f"{TerminalColors.OKCYAN}Updated {di}{TerminalColors.ENDC}"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
self.di_skipped.append(di)
|
self.di_skipped.append(di)
|
||||||
if debug:
|
log_message = f"{TerminalColors.YELLOW}Skipping update for {di}{TerminalColors.ENDC}"
|
||||||
logger.info(
|
|
||||||
f"{TerminalColors.YELLOW}Skipping update for {di}{TerminalColors.ENDC}"
|
# Log the action if debug mode is on
|
||||||
)
|
if debug:
|
||||||
|
logger.info(log_message)
|
||||||
|
|
||||||
|
# Bulk update the federal agency field in DomainInformation objects
|
||||||
DomainInformation.objects.bulk_update(self.di_to_update, ["federal_agency"])
|
DomainInformation.objects.bulk_update(self.di_to_update, ["federal_agency"])
|
||||||
|
|
||||||
|
# Get a list of each domain we changed
|
||||||
corrected_domains = DomainInformation.objects.filter(domain__name__in=domain_names)
|
corrected_domains = DomainInformation.objects.filter(domain__name__in=domain_names)
|
||||||
|
|
||||||
# After the update has happened, do a sweep of what we get back.
|
# After the update has happened, do a sweep of what we get back.
|
||||||
# If the fields we expect to update are still None, then something is wrong.
|
# If the fields we expect to update are still None, then something is wrong.
|
||||||
for di in corrected_domains:
|
for di in corrected_domains:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue