Commit a3674879 authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

plug django_filters on DRF

parent 277462c0
Pipeline #1091 passed with stages
in 1 minute and 1 second
......@@ -148,6 +148,12 @@ LOGGING = {
},
}
REST_FRAMEWORK = {
'DEFAULT_FILTER_BACKENDS': (
'django_filters.rest_framework.DjangoFilterBackend',
),
}
DJANGO_TABLES2_TEMPLATE = 'rainboard/tables.html'
RAINBOARD_DATA = Path('/srv/dashboard')
RAINBOARD_GITS = RAINBOARD_DATA / 'repositories'
......
......@@ -3,7 +3,7 @@ import django_filters
from . import models
class ProjectFilter(django_filters.FilterSet):
class ProjectFilter(django_filters.rest_framework.FilterSet):
name = django_filters.CharFilter(lookup_expr='icontains')
class Meta:
......@@ -11,7 +11,7 @@ class ProjectFilter(django_filters.FilterSet):
fields = ('name',)
class ContributorFilter(django_filters.FilterSet):
class ContributorFilter(django_filters.rest_framework.FilterSet):
name = django_filters.CharFilter(field_name='contributorname__name', label='name', lookup_expr='icontains')
mail = django_filters.CharFilter(field_name='contributormail__mail', label='mail', lookup_expr='icontains')
project = django_filters.CharFilter(field_name='projects__name', label='project', lookup_expr='icontains')
......
......@@ -131,26 +131,31 @@ class AuthenticatedOrReadOnlyModelViewSet(viewsets.ModelViewSet):
class NamespaceViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Namespace.objects.all()
serializer_class = serializers.NamespaceSerializer
filterset_fields = ('name', 'slug')
class LicenseViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.License.objects.all()
serializer_class = serializers.LicenseSerializer
filterset_fields = ('name', 'spdx_id')
class ForgeViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Forge.objects.all()
serializer_class = serializers.ForgeSerializer
filterset_fields = ('name', 'slug')
class ProjectViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Project.objects.all()
serializer_class = serializers.ProjectSerializer
filterset_class = filters.ProjectFilter
class RepoViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Repo.objects.all()
serializer_class = serializers.RepoSerializer
filterset_fields = ('name', 'slug')
class BranchViewSet(AuthenticatedOrReadOnlyModelViewSet):
......@@ -159,13 +164,15 @@ class BranchViewSet(AuthenticatedOrReadOnlyModelViewSet):
class TargetViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Target.objects.all()
queryset = models.Target.objects.active()
serializer_class = serializers.TargetSerializer
filterset_fields = ('name', 'slug')
class RobotpkgViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Robotpkg.objects.all()
serializer_class = serializers.RobotpkgSerializer
filterset_fields = ('name', 'slug')
class ImageViewSet(AuthenticatedOrReadOnlyModelViewSet):
......@@ -176,6 +183,7 @@ class ImageViewSet(AuthenticatedOrReadOnlyModelViewSet):
class ContributorViewSet(AuthenticatedOrReadOnlyModelViewSet):
queryset = models.Contributor.objects.all()
serializer_class = serializers.ContributorSerializer
filterset_class = filters.ContributorFilter
class ContributorNameViewSet(AuthenticatedOrReadOnlyModelViewSet):
......
Markdown is supported
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