Merge branch 'za/1909-change-org-field-to-new-format' into za/1911-fill-new-org-type-column

This commit is contained in:
zandercymatics 2024-04-08 09:45:17 -06:00
commit fb35ab17af
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7

View file

@ -105,7 +105,16 @@ def _update_org_type_from_generic_org_and_election(instance, org_map):
if generic_org_type not in org_map: if generic_org_type not in org_map:
# Election board should always be reset to None if the record # Election board should always be reset to None if the record
# can't have one. For example, federal. # can't have one. For example, federal.
instance.is_election_board = None if instance.is_election_board is not None:
# This maintains data consistency.
# There is no avenue for this to occur in the UI,
# as such - this can only occur if the object is initialized in this way.
# Or if there are pre-existing data.
logger.warning(
"create_or_update_organization_type() -> is_election_board "
f"cannot exist for {generic_org_type}. Setting to None."
)
instance.is_election_board = None
instance.organization_type = generic_org_type instance.organization_type = generic_org_type
else: else:
# This can only happen with manual data tinkering, which causes these to be out of sync. # This can only happen with manual data tinkering, which causes these to be out of sync.
@ -139,6 +148,14 @@ def _update_generic_org_and_election_from_org_type(instance, election_org_map, g
if current_org_type in generic_org_map: if current_org_type in generic_org_map:
instance.is_election_board = False instance.is_election_board = False
else: else:
# This maintains data consistency.
# There is no avenue for this to occur in the UI,
# as such - this can only occur if the object is initialized in this way.
# Or if there are pre-existing data.
logger.warning(
"create_or_update_organization_type() -> is_election_board "
f"cannot exist for {current_org_type}. Setting to None."
)
instance.is_election_board = None instance.is_election_board = None