Verified Commit 2cef58e6 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Can now search in library tracks

parent 57bf43bb
import django_filters
from django.db import models
from import utils
('me', 'Only me'),
......@@ -25,3 +29,15 @@ def privacy_level_query(user, lookup_field='privacy_level'):
'followers', 'instance', 'everyone'
class SearchFilter(django_filters.CharFilter):
def __init__(self, *args, **kwargs):
self.search_fields = kwargs.pop('search_fields')
super().__init__(*args, **kwargs)
def filter(self, qs, value):
if not value:
return qs
query = utils.get_query(value, self.search_fields)
return qs.filter(query)
import django_filters
from funkwhale_api.common import fields
from . import models
......@@ -19,6 +21,12 @@ class LibraryFilter(django_filters.FilterSet):
class LibraryTrackFilter(django_filters.FilterSet):
library = django_filters.CharFilter('library__uuid')
q = fields.SearchFilter(search_fields=[
class Meta:
model = models.LibraryTrack
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment