api.py 1.72 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
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
40
41
router = routers.DefaultRouter()

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