Commit 96dc0a4c authored by Nicolas Joyard's avatar Nicolas Joyard

Add chambers to API

parent 5ff0f92c
......@@ -8,6 +8,7 @@ from rest_framework import (
)
from representatives.serializers import (
ChamberSerializer,
ConstituencySerializer,
GroupSerializer,
MandateSerializer,
......@@ -17,6 +18,7 @@ from representatives.serializers import (
from .models import (
Address,
Chamber,
Constituency,
Group,
Mandate,
......@@ -122,3 +124,9 @@ class GroupViewSet(viewsets.ReadOnlyModelViewSet):
pagination_class = DefaultWebPagination
queryset = Group.objects.all()
serializer_class = GroupSerializer
class ChamberViewSet(viewsets.ReadOnlyModelViewSet):
pagination_class = DefaultWebPagination
queryset = Chamber.objects.all()
serializer_class = ChamberSerializer
......@@ -13,6 +13,13 @@ class CountrySerializer(serializers.ModelSerializer):
fields = ('name', 'code')
class ChamberSerializer(serializers.ModelSerializer):
class Meta:
model = models.Chamber
fields = ('name', 'abbreviation', 'country')
class EmailSerializer(serializers.ModelSerializer):
class Meta:
......
[{"name":"European Parliament","abbreviation":"EP","country":null}]
\ No newline at end of file
......@@ -20,6 +20,9 @@ class RepresentativeManagerTest(test.TestCase):
def test_mandates_api(self):
self.functional_test(1, '/api/mandates/?format=json')
def test_chambers_api(self):
self.functional_test(1, '/api/chambers/?format=json')
def test_representatives_api(self):
"""
Queries:
......
......@@ -3,6 +3,7 @@ from django.conf.urls import include, url
from rest_framework import routers
from representatives.api import (
ChamberViewSet,
ConstituencyViewSet,
GroupViewSet,
MandateViewSet,
......@@ -10,6 +11,7 @@ from representatives.api import (
)
router = routers.DefaultRouter()
router.register(r'chambers', ChamberViewSet)
router.register(r'constituencies', ConstituencyViewSet)
router.register(r'groups', GroupViewSet)
router.register(r'mandates', MandateViewSet)
......
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