Skip to content

Commit

Permalink
2950 updated search index (#2964)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
raftmsohani and ADPennington authored Jul 16, 2024
1 parent b2b3356 commit 66542e8
Show file tree
Hide file tree
Showing 5 changed files with 217 additions and 1 deletion.
16 changes: 15 additions & 1 deletion tdrs-backend/tdpservice/search_indexes/admin/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
Original file line number Diff line number Diff line change
@@ -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'},
),
]
35 changes: 35 additions & 0 deletions tdrs-backend/tdpservice/search_indexes/models/ssp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
35 changes: 35 additions & 0 deletions tdrs-backend/tdpservice/search_indexes/models/tanf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
35 changes: 35 additions & 0 deletions tdrs-backend/tdpservice/search_indexes/models/tribal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 66542e8

Please sign in to comment.