Skip to content

Commit

Permalink
Additional DF Filters (#3204)
Browse files Browse the repository at this point in the history
* - Add extra filters
- remove erroneous code block

* - Updated order of filters
- Removed program type filter since it is redundant

* - remove filter

* - remove id from filters

---------

Co-authored-by: raftmsohani <[email protected]>
Co-authored-by: Alex P. <[email protected]>
Co-authored-by: Andrew <[email protected]>
  • Loading branch information
4 people authored Oct 11, 2024
1 parent 7844b93 commit 51981aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 28 deletions.
11 changes: 6 additions & 5 deletions tdrs-backend/tdpservice/data_files/admin/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# from tdpservice.core.filters import custom_filter_title
from tdpservice.data_files.models import DataFile, LegacyFileTransfer
from tdpservice.parsers.models import DataFileSummary, ParserError
from tdpservice.data_files.admin.filters import DataFileSummaryPrgTypeFilter, LatestReparseEvent, VersionFilter
from tdpservice.data_files.admin.filters import LatestReparseEvent, VersionFilter
from django.conf import settings
from django.utils.html import format_html
from datetime import datetime, timedelta, timezone
Expand Down Expand Up @@ -113,14 +113,15 @@ def queryset(self, request, queryset):
]

list_filter = [
'stt',
'year',
'quarter',
'section',
'stt',
'summary__status',
'stt__type',
'stt__region',
'user',
'year',
SubmissionDateFilter,
'summary__status',
DataFileSummaryPrgTypeFilter,
LatestReparseEvent,
VersionFilter,
]
Expand Down
21 changes: 0 additions & 21 deletions tdrs-backend/tdpservice/data_files/admin/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,6 @@
from tdpservice.search_indexes.models.reparse_meta import ReparseMeta
from tdpservice.core.filters import MostRecentVersionFilter

class DataFileSummaryPrgTypeFilter(admin.SimpleListFilter):
"""Admin class filter for Program Type on datafile model."""

title = 'Program Type'
parameter_name = 'program_type'

def lookups(self, request, model_admin):
"""Return a list of tuples."""
return [
('TAN', 'TAN'),
('SSP', 'SSP'),
]

def queryset(self, request, queryset):
"""Return a queryset."""
if self.value():
query_set_ids = [df.id for df in queryset if df.prog_type == self.value()]
return queryset.filter(id__in=query_set_ids)
else:
return queryset


class LatestReparseEvent(admin.SimpleListFilter):
"""Filter class to filter files based on the latest reparse event."""
Expand Down
2 changes: 0 additions & 2 deletions tdrs-backend/tdpservice/data_files/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ def prog_type(self):
# e.g., 'SSP Closed Case Data'
if self.section.startswith('SSP'):
return 'SSP'
elif self.section.startswith('Tribal'):
return 'TAN' # problematic, do we need to infer tribal entirely from tribe/fips code?
else:
return 'TAN'

Expand Down

0 comments on commit 51981aa

Please sign in to comment.