kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Import request filter
rodzic
dcb1915a7b
commit
dac47da584
|
@ -0,0 +1,14 @@
|
|||
import django_filters
|
||||
|
||||
from . import models
|
||||
|
||||
|
||||
class ImportRequestFilter(django_filters.FilterSet):
|
||||
|
||||
class Meta:
|
||||
model = models.ImportRequest
|
||||
fields = {
|
||||
'artist_name': ['exact', 'iexact', 'startswith', 'icontains'],
|
||||
'status': ['exact'],
|
||||
'user__username': ['exact'],
|
||||
}
|
|
@ -5,6 +5,7 @@ from rest_framework.decorators import detail_route
|
|||
|
||||
from funkwhale_api.music.views import SearchMixin
|
||||
|
||||
from . import filters
|
||||
from . import models
|
||||
from . import serializers
|
||||
|
||||
|
@ -17,8 +18,13 @@ class ImportRequestViewSet(
|
|||
viewsets.GenericViewSet):
|
||||
|
||||
serializer_class = serializers.ImportRequestSerializer
|
||||
queryset = models.ImportRequest.objects.all().select_related()
|
||||
queryset = (
|
||||
models.ImportRequest.objects.all()
|
||||
.select_related()
|
||||
.order_by('-creation_date'))
|
||||
search_fields = ['artist_name', 'album_name', 'comment']
|
||||
filter_class = filters.ImportRequestFilter
|
||||
ordering_fields = ('id', 'artist_name', 'creation_date', 'status')
|
||||
|
||||
def perform_create(self, serializer):
|
||||
return serializer.save(user=self.request.user)
|
||||
|
|
Ładowanie…
Reference in New Issue