Commit a60f930f authored by Nicolas Joyard's avatar Nicolas Joyard

Add RQLFilterBackend to whole API

parent ea84bcb7
from rest_framework import routers
from rql_filter.backend import RQLFilterBackend as RQLBackend
from representatives.api import (
CountryViewSet,
ChamberViewSet,
......@@ -23,18 +25,55 @@ from representatives_recommendations.api import (
)
class RQLCountryViewSet(CountryViewSet):
filter_backends = CountryViewSet.filter_backends + [RQLBackend]
class RQLChamberViewSet(ChamberViewSet):
filter_backends = ChamberViewSet.filter_backends + [RQLBackend]
class RQLConstituencyViewSet(ConstituencyViewSet):
filter_backends = ConstituencyViewSet.filter_backends + [RQLBackend]
class RQLGroupViewSet(GroupViewSet):
filter_backends = GroupViewSet.filter_backends + [RQLBackend]
class RQLMandateViewSet(MandateViewSet):
filter_backends = MandateViewSet.filter_backends + (RQLBackend,)
class RQLRepresentativeViewSet(RepresentativeViewSet):
filter_backends = RepresentativeViewSet.filter_backends + (RQLBackend,)
class RQLDossierViewSet(DossierViewSet):
filter_backends = DossierViewSet.filter_backends + (RQLBackend,)
class RQLProposalViewSet(ProposalViewSet):
filter_backends = ProposalViewSet.filter_backends + (RQLBackend,)
class RQLVoteViewSet(VoteViewSet):
filter_backends = VoteViewSet.filter_backends + (RQLBackend,)
router = routers.DefaultRouter()
router.register('countries', CountryViewSet, 'api-country')
router.register('chambers', ChamberViewSet, 'api-chamber')
router.register('constituencies', ConstituencyViewSet, 'api-constituency')
router.register('dossiers', DossierViewSet, 'api-dossier')
router.register('countries', RQLCountryViewSet, 'api-country')
router.register('chambers', RQLChamberViewSet, 'api-chamber')
router.register('constituencies', RQLConstituencyViewSet, 'api-constituency')
router.register('dossiers', RQLDossierViewSet, 'api-dossier')
router.register('dossier_scores', DossierScoreViewSet, 'api-dossierscore')
router.register('groups', GroupViewSet, 'api-group')
router.register('mandates', MandateViewSet, 'api-mandate')
router.register('proposals', ProposalViewSet, 'api-proposal')
router.register('groups', RQLGroupViewSet, 'api-group')
router.register('mandates', RQLMandateViewSet, 'api-mandate')
router.register('proposals', RQLProposalViewSet, 'api-proposal')
router.register('recommendations', RecommendationViewSet, 'api-recommendation')
router.register('representatives', RepresentativeViewSet, 'api-representative')
router.register('representatives', RQLRepresentativeViewSet,
'api-representative')
router.register('scores', RepresentativeScoreViewSet, 'api-score')
router.register('vote_scores', VoteScoreViewSet, 'api-votescore')
router.register('votes', VoteViewSet, 'api-vote')
router.register('votes', RQLVoteViewSet, 'api-vote')
......@@ -3,6 +3,8 @@ from rest_framework import (
viewsets,
)
from rql_filter.backend import RQLFilterBackend
from representatives.api import DefaultWebPagination
from .models import (
......@@ -28,7 +30,8 @@ class DossierScoreViewSet(viewsets.ReadOnlyModelViewSet):
filter_backends = (
filters.DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter
filters.OrderingFilter,
RQLFilterBackend
)
filter_fields = {
'id': ['exact'],
......@@ -50,7 +53,8 @@ class RecommendationViewSet(viewsets.ReadOnlyModelViewSet):
filter_backends = (
filters.DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter
filters.OrderingFilter,
RQLFilterBackend
)
filter_fields = {
'id': ['exact'],
......@@ -73,7 +77,8 @@ class RepresentativeScoreViewSet(viewsets.ReadOnlyModelViewSet):
filter_backends = (
filters.DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter
filters.OrderingFilter,
RQLFilterBackend
)
filter_fields = {
'representative': ['exact'],
......@@ -102,7 +107,8 @@ class VoteScoreViewSet(viewsets.ReadOnlyModelViewSet):
filter_backends = (
filters.DjangoFilterBackend,
filters.SearchFilter,
filters.OrderingFilter
filters.OrderingFilter,
RQLFilterBackend
)
filter_fields = {
......
......@@ -19,6 +19,7 @@ setup(name='political-memory',
'django-libsass>=0.7,<0.8',
'django-representatives-votes==0.0.24',
'django-representatives==0.0.33',
'django-rql-filter>=0.1.3,<0.2',
'django-taggit>=0.17,<0.18',
'django>=1.8,<1.9',
'djangorestframework>=3,<4',
......
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