update to portfolio model and associated tests

This commit is contained in:
David Kennedy 2025-01-27 15:31:48 -05:00
parent 5c061fec30
commit d64a48934c
No known key found for this signature in database
GPG key ID: 6528A5386E66B96B
2 changed files with 42 additions and 0 deletions

View file

@ -122,6 +122,16 @@ class Portfolio(TimeStampedModel):
if self.state_territory != self.StateTerritoryChoices.PUERTO_RICO and self.urbanization:
self.urbanization = None
# If the org type is federal, and org federal agency is not blank, and is a federal agency
# overwrite the organization name with the federal agency's agency
if (
self.organization_type == self.OrganizationChoices.FEDERAL
and self.federal_agency
and self.federal_agency != FederalAgency.get_non_federal_agency()
and self.federal_agency.agency
):
self.organization_name = self.federal_agency.agency
super().save(*args, **kwargs)
@property