From 7c8d7d293c5fda1c430fb6749190864a2d44b845 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:50:15 -0600 Subject: [PATCH 1/2] Simplify _update_org_type_from_generic_org_and_election --- src/registrar/signals.py | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/registrar/signals.py b/src/registrar/signals.py index 301459f93..135336b04 100644 --- a/src/registrar/signals.py +++ b/src/registrar/signals.py @@ -108,25 +108,18 @@ def _update_org_type_from_generic_org_and_election(instance, org_map): # We convert to a string because the enum types are different. generic_org_type = str(instance.generic_org_type) - - # If the election board is none, then it tells us that it is an invalid field. - # Such as federal, interstate, or school_district. - if instance.is_election_board is None and generic_org_type not in org_map: - instance.organization_type = generic_org_type - return instance - elif instance.is_election_board is None and generic_org_type in org_map: - # This can only happen with manual data tinkering, which causes these to be out of sync. - instance.is_election_board = False - logger.warning("create_or_update_organization_type() -> is_election_board is out of sync. Updating value.") - - if generic_org_type in org_map: - # Swap to the election type if it is an election board. Otherwise, stick to the normal one. - instance.organization_type = org_map[generic_org_type] if instance.is_election_board else generic_org_type - else: - # Election board should be reset to None if the record + if generic_org_type not in generic_org_type: + # Election board should always be reset to None if the record # can't have one. For example, federal. - instance.organization_type = generic_org_type instance.is_election_board = None + instance.organization_type = generic_org_type + else: + # This can only happen with manual data tinkering, which causes these to be out of sync. + if instance.is_election_board is None: + logger.warning("create_or_update_organization_type() -> is_election_board is out of sync. Updating value.") + instance.is_election_board = False + + instance.organization_type = org_map[generic_org_type] if instance.is_election_board else generic_org_type def _update_generic_org_and_election_from_org_type(instance, election_org_map, generic_org_map): From 20067eec699715607cd4f19b69494eb2fa2fa8b2 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Tue, 2 Apr 2024 14:19:04 -0600 Subject: [PATCH 2/2] Fix typo --- src/registrar/signals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/registrar/signals.py b/src/registrar/signals.py index 135336b04..ad287219d 100644 --- a/src/registrar/signals.py +++ b/src/registrar/signals.py @@ -108,7 +108,7 @@ def _update_org_type_from_generic_org_and_election(instance, org_map): # We convert to a string because the enum types are different. generic_org_type = str(instance.generic_org_type) - if generic_org_type not in generic_org_type: + if generic_org_type not in org_map: # Election board should always be reset to None if the record # can't have one. For example, federal. instance.is_election_board = None