mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 20:49:16 +02:00
Can now filter by import status on library tracks
This commit is contained in:
parent
183bbe3ad6
commit
5fee42f896
2 changed files with 30 additions and 2 deletions
|
@ -24,6 +24,7 @@ class LibraryFilter(django_filters.FilterSet):
|
|||
|
||||
class LibraryTrackFilter(django_filters.FilterSet):
|
||||
library = django_filters.CharFilter('library__uuid')
|
||||
imported = django_filters.CharFilter(method='filter_imported')
|
||||
q = fields.SearchFilter(search_fields=[
|
||||
'artist_name',
|
||||
'title',
|
||||
|
@ -31,6 +32,13 @@ class LibraryTrackFilter(django_filters.FilterSet):
|
|||
'library__actor__domain',
|
||||
])
|
||||
|
||||
def filter_imported(self, queryset, field_name, value):
|
||||
if value.lower() in ['true', '1', 'yes']:
|
||||
queryset = queryset.filter(local_track_file__isnull=False)
|
||||
elif value.lower() in ['false', '0', 'no']:
|
||||
queryset = queryset.filter(local_track_file__isnull=True)
|
||||
return queryset
|
||||
|
||||
class Meta:
|
||||
model = models.LibraryTrack
|
||||
fields = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue