mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-16 17:47:02 +02:00
Merge branch 'za/1909-change-org-field-to-new-format' into za/1911-fill-new-org-type-column
This commit is contained in:
commit
0961ecbb33
1 changed files with 10 additions and 17 deletions
|
@ -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.
|
# We convert to a string because the enum types are different.
|
||||||
generic_org_type = str(instance.generic_org_type)
|
generic_org_type = str(instance.generic_org_type)
|
||||||
|
if generic_org_type not in org_map:
|
||||||
# If the election board is none, then it tells us that it is an invalid field.
|
# Election board should always be reset to None if the record
|
||||||
# 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
|
|
||||||
# can't have one. For example, federal.
|
# can't have one. For example, federal.
|
||||||
instance.organization_type = generic_org_type
|
|
||||||
instance.is_election_board = None
|
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):
|
def _update_generic_org_and_election_from_org_type(instance, election_org_map, generic_org_map):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue