api.py 2.42 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
    DossierScoreViewSet,
22 23
    RecommendationViewSet,
    RepresentativeScoreViewSet,
24
    VoteScoreViewSet
25 26 27
)


28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
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,)


Jamesie Pic's avatar
Jamesie Pic committed
64 65
router = routers.DefaultRouter()

66 67 68 69
router.register('countries', RQLCountryViewSet, 'api-country')
router.register('chambers', RQLChamberViewSet, 'api-chamber')
router.register('constituencies', RQLConstituencyViewSet, 'api-constituency')
router.register('dossiers', RQLDossierViewSet, 'api-dossier')
Nicolas Joyard's avatar
Nicolas Joyard committed
70
router.register('dossier_scores', DossierScoreViewSet, 'api-dossierscore')
71 72 73
router.register('groups', RQLGroupViewSet, 'api-group')
router.register('mandates', RQLMandateViewSet, 'api-mandate')
router.register('proposals', RQLProposalViewSet, 'api-proposal')
Nicolas Joyard's avatar
Nicolas Joyard committed
74
router.register('recommendations', RecommendationViewSet, 'api-recommendation')
75 76
router.register('representatives', RQLRepresentativeViewSet,
                'api-representative')
Nicolas Joyard's avatar
Nicolas Joyard committed
77 78
router.register('scores', RepresentativeScoreViewSet, 'api-score')
router.register('vote_scores', VoteScoreViewSet, 'api-votescore')
79
router.register('votes', RQLVoteViewSet, 'api-vote')