Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Political Memory
django-representatives
Commits
96dc0a4c
Commit
96dc0a4c
authored
Jul 08, 2016
by
Nicolas Joyard
Browse files
Add chambers to API
parent
5ff0f92c
Changes
6
Hide whitespace changes
Inline
Side-by-side
representatives/api.py
View file @
96dc0a4c
...
...
@@ -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
representatives/serializers.py
View file @
96dc0a4c
...
...
@@ -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
:
...
...
representatives/tests/response_fixtures/RepresentativeManagerTest.test_chambers_api.content
0 → 100644
View file @
96dc0a4c
[{"name":"European Parliament","abbreviation":"EP","country":null}]
\ No newline at end of file
representatives/tests/response_fixtures/RepresentativeManagerTest.test_chambers_api.metadata
0 → 100644
View file @
96dc0a4c
{
"status_code": 200
}
\ No newline at end of file
representatives/tests/test_views.py
View file @
96dc0a4c
...
...
@@ -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:
...
...
representatives/tests/urls.py
View file @
96dc0a4c
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment