Federal agency changes

This commit is contained in:
zandercymatics 2024-09-27 14:20:03 -06:00
parent 9a7a65d958
commit 3290137833
No known key found for this signature in database
GPG key ID: FF4636ABEC9682B7
5 changed files with 42 additions and 12 deletions

View file

@ -3291,7 +3291,7 @@ class FederalAgencyResource(resources.ModelResource):
class FederalAgencyAdmin(ListHeaderAdmin, ImportExportModelAdmin): class FederalAgencyAdmin(ListHeaderAdmin, ImportExportModelAdmin):
list_display = ["agency"] list_display = ["agency"]
search_fields = ["agency"] search_fields = ["agency"]
search_help_text = "Search by agency name." search_help_text = "Search by federal agency."
ordering = ["agency"] ordering = ["agency"]
resource_classes = [FederalAgencyResource] resource_classes = [FederalAgencyResource]

View file

@ -42,7 +42,7 @@ class Command(BaseCommand, PopulateScriptTemplate):
"""For each record, update the initials and is_fceb field if data exists for it""" """For each record, update the initials and is_fceb field if data exists for it"""
initials, agency_status = self.federal_agency_dict.get(record.agency) initials, agency_status = self.federal_agency_dict.get(record.agency)
record.initials = initials record.acronym = initials
if agency_status and isinstance(agency_status, str) and agency_status.strip().upper() == "FCEB": if agency_status and isinstance(agency_status, str) and agency_status.strip().upper() == "FCEB":
record.is_fceb = True record.is_fceb = True
else: else:

View file

@ -1,4 +1,4 @@
# Generated by Django 4.2.10 on 2024-09-26 15:09 # Generated by Django 4.2.10 on 2024-09-27 20:12
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
@ -12,6 +12,37 @@ class Migration(migrations.Migration):
] ]
operations = [ operations = [
migrations.RemoveField(
model_name="federalagency",
name="initials",
),
migrations.AddField(
model_name="federalagency",
name="acronym",
field=models.CharField(
blank=True,
help_text="Acronym commonly used to reference the federal agency (Optional)",
max_length=10,
null=True,
),
),
migrations.AlterField(
model_name="federalagency",
name="federal_type",
field=models.CharField(
blank=True,
choices=[("executive", "Executive"), ("judicial", "Judicial"), ("legislative", "Legislative")],
max_length=20,
null=True,
),
),
migrations.AlterField(
model_name="federalagency",
name="is_fceb",
field=models.BooleanField(
blank=True, help_text="Federal Civilian Executive Branch (FCEB)", null=True, verbose_name="FCEB"
),
),
migrations.AlterField( migrations.AlterField(
model_name="portfolio", model_name="portfolio",
name="federal_agency", name="federal_agency",

View file

@ -22,21 +22,20 @@ class FederalAgency(TimeStampedModel):
choices=BranchChoices.choices, choices=BranchChoices.choices,
null=True, null=True,
blank=True, blank=True,
help_text="Federal agency type (executive, judicial, legislative, etc.)",
) )
initials = models.CharField( acronym = models.CharField(
max_length=10, max_length=10,
null=True, null=True,
blank=True, blank=True,
help_text="Agency initials", help_text="Acronym commonly used to reference the federal agency (Optional)",
) )
is_fceb = models.BooleanField( is_fceb = models.BooleanField(
null=True, null=True,
blank=True, blank=True,
verbose_name="FCEB", verbose_name="FCEB",
help_text="Determines if this agency is FCEB", help_text="Federal Civilian Executive Branch (FCEB)",
) )
def __str__(self) -> str: def __str__(self) -> str:

View file

@ -1387,18 +1387,18 @@ class TestPopulateFederalAgencyInitialsAndFceb(TestCase):
self.agency4.refresh_from_db() self.agency4.refresh_from_db()
# Check if FederalAgency objects were updated correctly # Check if FederalAgency objects were updated correctly
self.assertEqual(self.agency1.initials, "ABMC") self.assertEqual(self.agency1.acronym, "ABMC")
self.assertTrue(self.agency1.is_fceb) self.assertTrue(self.agency1.is_fceb)
self.assertEqual(self.agency2.initials, "ACHP") self.assertEqual(self.agency2.acronym, "ACHP")
self.assertTrue(self.agency2.is_fceb) self.assertTrue(self.agency2.is_fceb)
# We expect that this field doesn't have any data, # We expect that this field doesn't have any data,
# as none is specified in the CSV # as none is specified in the CSV
self.assertIsNone(self.agency3.initials) self.assertIsNone(self.agency3.acronym)
self.assertIsNone(self.agency3.is_fceb) self.assertIsNone(self.agency3.is_fceb)
self.assertEqual(self.agency4.initials, "KC") self.assertEqual(self.agency4.acronym, "KC")
self.assertFalse(self.agency4.is_fceb) self.assertFalse(self.agency4.is_fceb)
@less_console_noise_decorator @less_console_noise_decorator
@ -1411,7 +1411,7 @@ class TestPopulateFederalAgencyInitialsAndFceb(TestCase):
# Verify that the missing agency was not updated # Verify that the missing agency was not updated
missing_agency.refresh_from_db() missing_agency.refresh_from_db()
self.assertIsNone(missing_agency.initials) self.assertIsNone(missing_agency.acronym)
self.assertIsNone(missing_agency.is_fceb) self.assertIsNone(missing_agency.is_fceb)