mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-11 20:19:38 +02:00
Linting
This commit is contained in:
parent
673a858bc3
commit
c26618bff1
1 changed files with 10 additions and 8 deletions
|
@ -41,6 +41,7 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
"""
|
"""
|
||||||
A helper that manages the "organization_type" field in DomainRequest and DomainInformation
|
A helper that manages the "organization_type" field in DomainRequest and DomainInformation
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, sender, instance, generic_org_to_org_map, election_org_to_generic_org_map):
|
def __init__(self, sender, instance, generic_org_to_org_map, election_org_to_generic_org_map):
|
||||||
# The "model type"
|
# The "model type"
|
||||||
self.sender = sender
|
self.sender = sender
|
||||||
|
@ -67,7 +68,7 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
self._handle_new_instance()
|
self._handle_new_instance()
|
||||||
else:
|
else:
|
||||||
self._handle_existing_instance()
|
self._handle_existing_instance()
|
||||||
|
|
||||||
return self.instance
|
return self.instance
|
||||||
|
|
||||||
def _handle_new_instance(self):
|
def _handle_new_instance(self):
|
||||||
|
@ -87,7 +88,7 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
self._update_org_type_from_generic_org_and_election()
|
self._update_org_type_from_generic_org_and_election()
|
||||||
elif generic_org_type_needs_update:
|
elif generic_org_type_needs_update:
|
||||||
self._update_generic_org_and_election_from_org_type()
|
self._update_generic_org_and_election_from_org_type()
|
||||||
|
|
||||||
# Update the field
|
# Update the field
|
||||||
self._update_fields(organization_type_needs_update, generic_org_type_needs_update)
|
self._update_fields(organization_type_needs_update, generic_org_type_needs_update)
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
def _update_fields(self, organization_type_needs_update, generic_org_type_needs_update):
|
def _update_fields(self, organization_type_needs_update, generic_org_type_needs_update):
|
||||||
"""
|
"""
|
||||||
Validates the conditions for updating organization and generic organization types.
|
Validates the conditions for updating organization and generic organization types.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If both organization_type_needs_update and generic_org_type_needs_update are True,
|
ValueError: If both organization_type_needs_update and generic_org_type_needs_update are True,
|
||||||
indicating an attempt to update both fields simultaneously, which is not allowed.
|
indicating an attempt to update both fields simultaneously, which is not allowed.
|
||||||
|
@ -133,7 +134,7 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
# this restraint.
|
# this restraint.
|
||||||
if organization_type_needs_update and generic_org_type_needs_update:
|
if organization_type_needs_update and generic_org_type_needs_update:
|
||||||
raise ValueError("Cannot update both org type and generic org type at the same time.")
|
raise ValueError("Cannot update both org type and generic org type at the same time.")
|
||||||
|
|
||||||
if organization_type_needs_update:
|
if organization_type_needs_update:
|
||||||
self._update_org_type_from_generic_org_and_election()
|
self._update_org_type_from_generic_org_and_election()
|
||||||
elif generic_org_type_needs_update:
|
elif generic_org_type_needs_update:
|
||||||
|
@ -162,12 +163,14 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
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.
|
||||||
if self.instance.is_election_board is None:
|
if self.instance.is_election_board is None:
|
||||||
logger.warning("create_or_update_organization_type() -> is_election_board is out of sync. Updating value.")
|
logger.warning(
|
||||||
|
"create_or_update_organization_type() -> is_election_board is out of sync. Updating value."
|
||||||
|
)
|
||||||
self.instance.is_election_board = False
|
self.instance.is_election_board = False
|
||||||
|
|
||||||
if self.instance.is_election_board:
|
if self.instance.is_election_board:
|
||||||
self.instance.organization_type = self.generic_org_to_org_map[generic_org_type]
|
self.instance.organization_type = self.generic_org_to_org_map[generic_org_type]
|
||||||
else:
|
else:
|
||||||
self.instance.organization_type = generic_org_type
|
self.instance.organization_type = generic_org_type
|
||||||
|
|
||||||
def _update_generic_org_and_election_from_org_type(self):
|
def _update_generic_org_and_election_from_org_type(self):
|
||||||
|
@ -242,4 +245,3 @@ class CreateOrUpdateOrganizationTypeHelper:
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue