filters.py 1.21 KB
Newer Older
1
2
3
4
5
import django_filters

from . import models


Eliot Berriot's avatar
Eliot Berriot committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
class LibraryFilter(django_filters.FilterSet):
    approved = django_filters.BooleanFilter('following__approved')

    class Meta:
        model = models.Library
        fields = {
            'approved': ['exact'],
            'federation_enabled': ['exact'],
            'download_files': ['exact'],
            'autoimport': ['exact'],
            'tracks_count': ['exact'],
        }


20
21
22
23
24
25
26
27
28
29
30
31
32
33
class LibraryTrackFilter(django_filters.FilterSet):
    library = django_filters.CharFilter('library__uuid')

    class Meta:
        model = models.LibraryTrack
        fields = {
            'library': ['exact'],
            'artist_name': ['exact', 'icontains'],
            'title': ['exact', 'icontains'],
            'album_title': ['exact', 'icontains'],
            'audio_mimetype': ['exact', 'icontains'],
        }


34
35
36
37
38
39
40
41
42
43
44
45
46
47
class FollowFilter(django_filters.FilterSet):
    ordering = django_filters.OrderingFilter(
        # tuple-mapping retains order
        fields=(
            ('creation_date', 'creation_date'),
            ('modification_date', 'modification_date'),
        ),
    )

    class Meta:
        model = models.Follow
        fields = {
            'approved': ['exact'],
        }