mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-06-14 16:34:49 +02:00
Linting
This commit is contained in:
parent
2e44a9099a
commit
493c03e7d4
3 changed files with 13 additions and 7 deletions
|
@ -163,7 +163,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
# Start with all DomainInformation objects
|
# Start with all DomainInformation objects
|
||||||
domain_informations = DomainInformation.objects.all()
|
domain_informations = DomainInformation.objects.all()
|
||||||
domain_informations_dict = {di.domain.name: di for di in domain_informations}
|
domain_informations_dict = {di.domain.name: di for di in domain_informations if di.domain is not None}
|
||||||
|
|
||||||
# Then, use each domain object to map TransitionDomain <--> DomainInformation
|
# Then, use each domain object to map TransitionDomain <--> DomainInformation
|
||||||
# Fetches all DomainInformations in one query.
|
# Fetches all DomainInformations in one query.
|
||||||
|
@ -177,7 +177,7 @@ class Command(BaseCommand):
|
||||||
zipcode__isnull=True,
|
zipcode__isnull=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
filtered_domain_informations_dict = {di.domain.name: di for di in domain_informations}
|
filtered_domain_informations_dict = {di.domain.name: di for di in domain_informations if di.domain is not None}
|
||||||
for item in transition_domains:
|
for item in transition_domains:
|
||||||
if item.domain_name not in domain_informations_dict:
|
if item.domain_name not in domain_informations_dict:
|
||||||
logger.error(f"Could not add {item.domain_name}. Domain does not exist.")
|
logger.error(f"Could not add {item.domain_name}. Domain does not exist.")
|
||||||
|
@ -196,6 +196,9 @@ class Command(BaseCommand):
|
||||||
# Based on the current domain, grab the right DomainInformation object.
|
# Based on the current domain, grab the right DomainInformation object.
|
||||||
current_domain_information = filtered_domain_informations_dict[item.domain_name]
|
current_domain_information = filtered_domain_informations_dict[item.domain_name]
|
||||||
|
|
||||||
|
if current_domain_information.domain is None or current_domain_information.domain.name is None:
|
||||||
|
raise LoadOrganizationError(code=LoadOrganizationErrorCodes.DOMAIN_NAME_WAS_NONE)
|
||||||
|
|
||||||
# Update fields
|
# Update fields
|
||||||
current_domain_information.address_line1 = item.address_line
|
current_domain_information.address_line1 = item.address_line
|
||||||
current_domain_information.city = item.city
|
current_domain_information.city = item.city
|
||||||
|
|
|
@ -9,7 +9,7 @@ import logging
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from typing import Dict
|
from typing import Dict, List
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from registrar.models.transition_domain import TransitionDomain
|
from registrar.models.transition_domain import TransitionDomain
|
||||||
from registrar.utility.errors import LoadOrganizationError, LoadOrganizationErrorCodes
|
from registrar.utility.errors import LoadOrganizationError, LoadOrganizationErrorCodes
|
||||||
|
@ -781,7 +781,7 @@ class OrganizationDataLoader:
|
||||||
# options.infer_filenames will always be false when not SETTING.DEBUG
|
# options.infer_filenames will always be false when not SETTING.DEBUG
|
||||||
self.parsed_data.parse_all_files(options.infer_filenames)
|
self.parsed_data.parse_all_files(options.infer_filenames)
|
||||||
|
|
||||||
self.tds_to_update = []
|
self.tds_to_update: List[TransitionDomain] = []
|
||||||
|
|
||||||
def update_organization_data_for_all(self):
|
def update_organization_data_for_all(self):
|
||||||
"""Updates org data for all TransitionDomains"""
|
"""Updates org data for all TransitionDomains"""
|
||||||
|
@ -870,7 +870,7 @@ class OrganizationDataLoader:
|
||||||
|
|
||||||
return transition_domain
|
return transition_domain
|
||||||
|
|
||||||
def get_org_info(self, domain_name) -> OrganizationAdhoc:
|
def get_org_info(self, domain_name) -> OrganizationAdhoc | None:
|
||||||
"""Maps an id given in get_domain_data to a organization_adhoc
|
"""Maps an id given in get_domain_data to a organization_adhoc
|
||||||
record which has its corresponding definition"""
|
record which has its corresponding definition"""
|
||||||
# Get a row in the domain_additional file. The id is the domain_name.
|
# Get a row in the domain_additional file. The id is the domain_name.
|
||||||
|
|
|
@ -64,9 +64,11 @@ class LoadOrganizationErrorCodes(IntEnum):
|
||||||
- 2 UPDATE_DOMAIN_INFO_FAILED
|
- 2 UPDATE_DOMAIN_INFO_FAILED
|
||||||
- 3 EMPTY_TRANSITION_DOMAIN_TABLE
|
- 3 EMPTY_TRANSITION_DOMAIN_TABLE
|
||||||
"""
|
"""
|
||||||
|
|
||||||
TRANSITION_DOMAINS_NOT_FOUND = 1
|
TRANSITION_DOMAINS_NOT_FOUND = 1
|
||||||
UPDATE_DOMAIN_INFO_FAILED = 2
|
UPDATE_DOMAIN_INFO_FAILED = 2
|
||||||
EMPTY_TRANSITION_DOMAIN_TABLE = 3
|
EMPTY_TRANSITION_DOMAIN_TABLE = 3
|
||||||
|
DOMAIN_NAME_WAS_NONE = 4
|
||||||
|
|
||||||
|
|
||||||
class LoadOrganizationError(Exception):
|
class LoadOrganizationError(Exception):
|
||||||
|
@ -79,7 +81,8 @@ class LoadOrganizationError(Exception):
|
||||||
"Could not find all desired TransitionDomains. " "(Possible data corruption?)"
|
"Could not find all desired TransitionDomains. " "(Possible data corruption?)"
|
||||||
),
|
),
|
||||||
LoadOrganizationErrorCodes.UPDATE_DOMAIN_INFO_FAILED: "Failed to update DomainInformation",
|
LoadOrganizationErrorCodes.UPDATE_DOMAIN_INFO_FAILED: "Failed to update DomainInformation",
|
||||||
LoadOrganizationErrorCodes.EMPTY_TRANSITION_DOMAIN_TABLE: "No TransitionDomains exist. Cannot update."
|
LoadOrganizationErrorCodes.EMPTY_TRANSITION_DOMAIN_TABLE: "No TransitionDomains exist. Cannot update.",
|
||||||
|
LoadOrganizationErrorCodes.DOMAIN_NAME_WAS_NONE: "DomainInformation was updated, but domain was None",
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, *args, code=None, **kwargs):
|
def __init__(self, *args, code=None, **kwargs):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue