api.py 1.75 KB
Newer Older
Jamesie Pic's avatar
Jamesie Pic committed
1 2
from rest_framework import routers

3 4
from rql_filter.backend import RQLFilterBackend as RQLBackend

Jamesie Pic's avatar
Jamesie Pic committed
5
from representatives.api import (
Nicolas Joyard's avatar
Nicolas Joyard committed
6
    CountryViewSet,
Nicolas Joyard's avatar
Nicolas Joyard committed
7
    ChamberViewSet,
Jamesie Pic's avatar
Jamesie Pic committed
8 9 10 11 12 13 14 15 16 17 18 19
    ConstituencyViewSet,
    GroupViewSet,
    MandateViewSet,
    RepresentativeViewSet,
)

from representatives_votes.api import (
    DossierViewSet,
    ProposalViewSet,
    VoteViewSet,
)

20
from representatives_recommendations.api import (
21 22 23 24
    RecommendationViewSet
)

from memopol_scores.api import (
25
    DossierScoreViewSet,
26
    RepresentativeScoreViewSet,
27
    VoteScoreViewSet
28 29 30
)


31 32 33 34 35 36 37 38 39 40 41 42
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,)


Jamesie Pic's avatar
Jamesie Pic committed
43 44
router = routers.DefaultRouter()

Nicolas Joyard's avatar
Nicolas Joyard committed
45 46 47
router.register('countries', CountryViewSet, 'api-country')
router.register('chambers', ChamberViewSet, 'api-chamber')
router.register('constituencies', ConstituencyViewSet, 'api-constituency')
48
router.register('dossiers', RQLDossierViewSet, 'api-dossier')
Nicolas Joyard's avatar
Nicolas Joyard committed
49
router.register('dossier_scores', DossierScoreViewSet, 'api-dossierscore')
Nicolas Joyard's avatar
Nicolas Joyard committed
50 51
router.register('groups', GroupViewSet, 'api-group')
router.register('mandates', MandateViewSet, 'api-mandate')
52
router.register('proposals', RQLProposalViewSet, 'api-proposal')
Nicolas Joyard's avatar
Nicolas Joyard committed
53
router.register('recommendations', RecommendationViewSet, 'api-recommendation')
Nicolas Joyard's avatar
Nicolas Joyard committed
54
router.register('representatives', RepresentativeViewSet,
55
                'api-representative')
Nicolas Joyard's avatar
Nicolas Joyard committed
56 57
router.register('scores', RepresentativeScoreViewSet, 'api-score')
router.register('vote_scores', VoteScoreViewSet, 'api-votescore')
58
router.register('votes', RQLVoteViewSet, 'api-vote')