Skip to content

Commit

Permalink
added filter for accepted/rejected
Browse files Browse the repository at this point in the history
  • Loading branch information
raftmsohani committed Sep 6, 2023
1 parent e2334bd commit 032f0ad
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tdrs-backend/tdpservice/data_files/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@
from ..core.utils import ReadOnlyAdminMixin
from .models import DataFile, LegacyFileTransfer

class DataFileSummaryListFilter(admin.SimpleListFilter):
"""Admin class filter for file status (accepted, rejected) for datafile model"""

title = 'status'
parameter_name = 'status'

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

def queryset(self, request, queryset):
"""Return a queryset."""
if self.value():
return queryset.filter(datafilesummary__status=self.value())
else:
return queryset


@admin.register(DataFile)
class DataFileAdmin(ReadOnlyAdminMixin, admin.ModelAdmin):
Expand All @@ -25,6 +45,7 @@ class DataFileAdmin(ReadOnlyAdminMixin, admin.ModelAdmin):
'user',
'year',
'version',
DataFileSummaryListFilter
]

@admin.register(LegacyFileTransfer)
Expand Down

0 comments on commit 032f0ad

Please sign in to comment.