api.py 1.95 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
    RecommendationViewSet
)

24 25 26 27
from memopol_themes.api import (
    ThemeViewSet
)

28
from memopol_scores.api import (
29
    DossierScoreViewSet,
30
    RepresentativeScoreViewSet,
31
    ThemeScoreViewSet,
32
    VoteScoreViewSet
33 34 35
)


36 37 38 39 40 41 42 43 44 45 46 47
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
48 49
router = routers.DefaultRouter()

Nicolas Joyard's avatar
Nicolas Joyard committed
50 51 52
router.register('countries', CountryViewSet, 'api-country')
router.register('chambers', ChamberViewSet, 'api-chamber')
router.register('constituencies', ConstituencyViewSet, 'api-constituency')
53
router.register('dossiers', RQLDossierViewSet, 'api-dossier')
Nicolas Joyard's avatar
Nicolas Joyard committed
54
router.register('dossier_scores', DossierScoreViewSet, 'api-dossierscore')
Nicolas Joyard's avatar
Nicolas Joyard committed
55 56
router.register('groups', GroupViewSet, 'api-group')
router.register('mandates', MandateViewSet, 'api-mandate')
57
router.register('proposals', RQLProposalViewSet, 'api-proposal')
Nicolas Joyard's avatar
Nicolas Joyard committed
58
router.register('recommendations', RecommendationViewSet, 'api-recommendation')
Nicolas Joyard's avatar
Nicolas Joyard committed
59
router.register('representatives', RepresentativeViewSet,
60
                'api-representative')
Nicolas Joyard's avatar
Nicolas Joyard committed
61
router.register('scores', RepresentativeScoreViewSet, 'api-score')
62 63
router.register('theme_scores', ThemeScoreViewSet, 'api-themescore')
router.register('themes', ThemeViewSet, 'api-themes')
Nicolas Joyard's avatar
Nicolas Joyard committed
64
router.register('vote_scores', VoteScoreViewSet, 'api-votescore')
65
router.register('votes', RQLVoteViewSet, 'api-vote')