mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-24 03:30:50 +02:00
Fix bug
This commit is contained in:
parent
941512c704
commit
022eb9bbaf
1 changed files with 8 additions and 6 deletions
|
@ -151,6 +151,8 @@ def _validate_new_instance(instance, election_org_to_generic_org_map, generic_or
|
||||||
"""
|
"""
|
||||||
Validates whether a new instance of DomainRequest or DomainInformation can proceed with the update
|
Validates whether a new instance of DomainRequest or DomainInformation can proceed with the update
|
||||||
based on the consistency between organization_type, generic_org_type, and is_election_board.
|
based on the consistency between organization_type, generic_org_type, and is_election_board.
|
||||||
|
|
||||||
|
Returns a boolean determining if execution should proceed or not.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# We conditionally accept both of these values to exist simultaneously, as long as
|
# We conditionally accept both of these values to exist simultaneously, as long as
|
||||||
|
@ -168,8 +170,8 @@ def _validate_new_instance(instance, election_org_to_generic_org_map, generic_or
|
||||||
is_election_type = "_election" in organization_type
|
is_election_type = "_election" in organization_type
|
||||||
can_have_election_board = organization_type in generic_org_to_org_map
|
can_have_election_board = organization_type in generic_org_to_org_map
|
||||||
|
|
||||||
election_board_mismatch = is_election_type != instance.is_election_board and can_have_election_board
|
election_board_mismatch = (is_election_type != instance.is_election_board) and can_have_election_board
|
||||||
org_type_mismatch = mapped_org_type is not None and generic_org_type != mapped_org_type
|
org_type_mismatch = mapped_org_type is not None and (generic_org_type != mapped_org_type)
|
||||||
if election_board_mismatch or org_type_mismatch:
|
if election_board_mismatch or org_type_mismatch:
|
||||||
message = (
|
message = (
|
||||||
"Cannot add organization_type and generic_org_type simultaneously "
|
"Cannot add organization_type and generic_org_type simultaneously "
|
||||||
|
@ -177,11 +179,11 @@ def _validate_new_instance(instance, election_org_to_generic_org_map, generic_or
|
||||||
)
|
)
|
||||||
raise ValueError(message)
|
raise ValueError(message)
|
||||||
|
|
||||||
should_proceed = True
|
return True
|
||||||
return should_proceed
|
elif not instance.organization_type and not instance.generic_org_type:
|
||||||
|
return False
|
||||||
else:
|
else:
|
||||||
should_proceed = not instance.organization_type and not instance.generic_org_type
|
return True
|
||||||
return should_proceed
|
|
||||||
|
|
||||||
|
|
||||||
@receiver(post_save, sender=User)
|
@receiver(post_save, sender=User)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue