From 66542e84faf4b8e4d7b1bc495b628e09d89afd7b Mon Sep 17 00:00:00 2001 From: raftmsohani <97037188+raftmsohani@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:01:34 -0400 Subject: [PATCH] 2950 updated search index (#2964) * 2950 updated model names * 2950 added changes for creating the filter * revert unused changes back * linting * removed unused file * 2950 removed unnecessary change * Fix linting error * 2950 added Territory to TANF * 2950 added Territory to TANF corrected linting --------- Co-authored-by: Alex P <63075587+ADPennington@users.noreply.github.com> --- .../search_indexes/admin/filters.py | 16 ++- ...029_tanf_tribal_ssp_alter_verbose_names.py | 97 +++++++++++++++++++ .../tdpservice/search_indexes/models/ssp.py | 35 +++++++ .../tdpservice/search_indexes/models/tanf.py | 35 +++++++ .../search_indexes/models/tribal.py | 35 +++++++ 5 files changed, 217 insertions(+), 1 deletion(-) create mode 100644 tdrs-backend/tdpservice/search_indexes/migrations/0029_tanf_tribal_ssp_alter_verbose_names.py diff --git a/tdrs-backend/tdpservice/search_indexes/admin/filters.py b/tdrs-backend/tdpservice/search_indexes/admin/filters.py index 517d27e48..36e1e66da 100644 --- a/tdrs-backend/tdpservice/search_indexes/admin/filters.py +++ b/tdrs-backend/tdpservice/search_indexes/admin/filters.py @@ -61,9 +61,23 @@ def _get_lookup_choices(self, request): else: type_query = Query(type=STT.EntityType.STATE) | Query(type=STT.EntityType.TERRITORY) queryset = queryset.filter(type_query) - return (queryset.distinct().order_by('name').values_list('name', flat=True)) + def lookups(self, request, model_admin): + """Available options in dropdown.""" + listing_record_type = [i for i in str(request.path).lower().split('/') if i not in ['/', '']][-1] + options = [] + if 'tribal' in listing_record_type: + objects = STT.objects.filter(type=STT.EntityType.TRIBE) + elif 'ssp' in listing_record_type: + objects = STT.objects.filter(ssp=True) + else: + objects = STT.objects.filter(Query(type=STT.EntityType.STATE) | Query(type=STT.EntityType.TERRITORY)) + for obj in objects: + options.append((obj.stt_code, _(obj.name))) + + return options + class FiscalPeriodFilter(SimpleListFilter): """Simple filter class to filter records based on datafile fiscal year.""" diff --git a/tdrs-backend/tdpservice/search_indexes/migrations/0029_tanf_tribal_ssp_alter_verbose_names.py b/tdrs-backend/tdpservice/search_indexes/migrations/0029_tanf_tribal_ssp_alter_verbose_names.py new file mode 100644 index 000000000..768c91d1c --- /dev/null +++ b/tdrs-backend/tdpservice/search_indexes/migrations/0029_tanf_tribal_ssp_alter_verbose_names.py @@ -0,0 +1,97 @@ +# Generated by Django 3.2.15 on 2024-05-15 16:49 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('search_indexes', '0028_education_level_to_string'), + ] + + operations = [ + migrations.AlterModelOptions( + name='ssp_m1', + options={'verbose_name': 'SSP M1'}, + ), + migrations.AlterModelOptions( + name='ssp_m2', + options={'verbose_name': 'SSP M2'}, + ), + migrations.AlterModelOptions( + name='ssp_m3', + options={'verbose_name': 'SSP M3'}, + ), + migrations.AlterModelOptions( + name='ssp_m4', + options={'verbose_name': 'SSP M4'}, + ), + migrations.AlterModelOptions( + name='ssp_m5', + options={'verbose_name': 'SSP M5'}, + ), + migrations.AlterModelOptions( + name='ssp_m6', + options={'verbose_name': 'SSP M6'}, + ), + migrations.AlterModelOptions( + name='ssp_m7', + options={'verbose_name': 'SSP M7'}, + ), + migrations.AlterModelOptions( + name='tanf_t1', + options={'verbose_name': 'TANF T1'}, + ), + migrations.AlterModelOptions( + name='tanf_t2', + options={'verbose_name': 'TANF T2'}, + ), + migrations.AlterModelOptions( + name='tanf_t3', + options={'verbose_name': 'TANF T3'}, + ), + migrations.AlterModelOptions( + name='tanf_t4', + options={'verbose_name': 'TANF T4'}, + ), + migrations.AlterModelOptions( + name='tanf_t5', + options={'verbose_name': 'TANF T5'}, + ), + migrations.AlterModelOptions( + name='tanf_t6', + options={'verbose_name': 'TANF T6'}, + ), + migrations.AlterModelOptions( + name='tanf_t7', + options={'verbose_name': 'TANF T7'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t1', + options={'verbose_name': 'Tribal TANF T1'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t2', + options={'verbose_name': 'Tribal TANF T2'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t3', + options={'verbose_name': 'Tribal TANF T3'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t4', + options={'verbose_name': 'Tribal TANF T4'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t5', + options={'verbose_name': 'Tribal TANF T5'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t6', + options={'verbose_name': 'Tribal TANF T6'}, + ), + migrations.AlterModelOptions( + name='tribal_tanf_t7', + options={'verbose_name': 'Tribal TANF T7'}, + ), + ] diff --git a/tdrs-backend/tdpservice/search_indexes/models/ssp.py b/tdrs-backend/tdpservice/search_indexes/models/ssp.py index bb5840323..78c035db2 100644 --- a/tdrs-backend/tdpservice/search_indexes/models/ssp.py +++ b/tdrs-backend/tdpservice/search_indexes/models/ssp.py @@ -12,6 +12,11 @@ class SSP_M1(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M1' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -78,6 +83,11 @@ class SSP_M2(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M2' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -165,6 +175,11 @@ class SSP_M3(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M3' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -206,6 +221,11 @@ class SSP_M4(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M4' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -240,6 +260,11 @@ class SSP_M5(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M5' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -286,6 +311,11 @@ class SSP_M6(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M6' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -318,6 +348,11 @@ class SSP_M7(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'SSP M7' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, diff --git a/tdrs-backend/tdpservice/search_indexes/models/tanf.py b/tdrs-backend/tdpservice/search_indexes/models/tanf.py index bac3f008d..c57ab89ed 100644 --- a/tdrs-backend/tdpservice/search_indexes/models/tanf.py +++ b/tdrs-backend/tdpservice/search_indexes/models/tanf.py @@ -12,6 +12,11 @@ class TANF_T1(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T1' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -81,6 +86,11 @@ class TANF_T2(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T2' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -170,6 +180,11 @@ class TANF_T3(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T3' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -211,6 +226,11 @@ class TANF_T4(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T4' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -243,6 +263,11 @@ class TANF_T5(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T5' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -292,6 +317,11 @@ class TANF_T6(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T6' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -329,6 +359,11 @@ class TANF_T7(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'TANF T7' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, diff --git a/tdrs-backend/tdpservice/search_indexes/models/tribal.py b/tdrs-backend/tdpservice/search_indexes/models/tribal.py index fd5ee805d..d42818336 100644 --- a/tdrs-backend/tdpservice/search_indexes/models/tribal.py +++ b/tdrs-backend/tdpservice/search_indexes/models/tribal.py @@ -14,6 +14,11 @@ class Tribal_TANF_T1(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T1' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -83,6 +88,11 @@ class Tribal_TANF_T2(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T2' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -155,6 +165,11 @@ class Tribal_TANF_T3(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T3' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -195,6 +210,11 @@ class Tribal_TANF_T4(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T4' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -226,6 +246,11 @@ class Tribal_TANF_T5(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T5' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -274,6 +299,11 @@ class Tribal_TANF_T6(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T6' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile, @@ -310,6 +340,11 @@ class Tribal_TANF_T7(models.Model): Mapped to an elastic search index. """ + class Meta: + """Meta class for the model.""" + + verbose_name = 'Tribal TANF T7' + id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) datafile = models.ForeignKey( DataFile,