Merge branch 'main' of https://github.com/cisagov/manage.get.gov into rh/2909-new-agency-field

This commit is contained in:
Rebecca Hsieh 2024-04-18 15:44:28 -07:00
commit c997d150e6
No known key found for this signature in database
26 changed files with 1290 additions and 99 deletions

View file

@ -487,6 +487,7 @@ class DomainRequest(TimeStampedModel):
is_election_board = models.BooleanField(
null=True,
blank=True,
verbose_name="election office",
help_text="Is your organization an election office?",
)
@ -559,12 +560,14 @@ class DomainRequest(TimeStampedModel):
choices=StateTerritoryChoices.choices,
null=True,
blank=True,
verbose_name="state / territory",
help_text="State, territory, or military post",
)
zipcode = models.CharField(
max_length=10,
null=True,
blank=True,
verbose_name="zip code",
help_text="Zip code",
db_index=True,
)
@ -666,6 +669,7 @@ class DomainRequest(TimeStampedModel):
null=True,
blank=True,
default=None,
verbose_name="submitted at",
help_text="Date submitted",
)
@ -675,14 +679,16 @@ class DomainRequest(TimeStampedModel):
help_text="Notes about this request",
)
def save(self, *args, **kwargs):
"""Save override for custom properties"""
def sync_organization_type(self):
"""
Updates the organization_type (without saving) to match
the is_election_board and generic_organization_type fields.
"""
# Define mappings between generic org and election org.
# These have to be defined here, as you'd get a cyclical import error
# otherwise.
# For any given organization type, return the "_election" variant.
# For any given organization type, return the "_ELECTION" enum equivalent.
# For example: STATE_OR_TERRITORY => STATE_OR_TERRITORY_ELECTION
generic_org_map = self.OrgChoicesElectionOffice.get_org_generic_to_org_election()
@ -701,6 +707,10 @@ class DomainRequest(TimeStampedModel):
# Actually updates the organization_type field
org_type_helper.create_or_update_organization_type()
def save(self, *args, **kwargs):
"""Save override for custom properties"""
self.sync_organization_type()
super().save(*args, **kwargs)
def __str__(self):