Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
memopol
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
32
Issues
32
List
Boards
Labels
Service Desk
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Political Memory
memopol
Commits
64804481
Commit
64804481
authored
Aug 04, 2016
by
Nicolas Joyard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix API inconsistencies
parent
45616b4e
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
57 additions
and
41 deletions
+57
-41
representatives_votes/serializers.py
representatives_votes/serializers.py
+24
-7
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossier.content
...e_fixtures/RepresentativeManagerTest.test_dossier.content
+8
-6
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossiers.content
..._fixtures/RepresentativeManagerTest.test_dossiers.content
+6
-4
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposal.content
..._fixtures/RepresentativeManagerTest.test_proposal.content
+1
-2
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposals.content
...fixtures/RepresentativeManagerTest.test_proposals.content
+6
-0
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_vote.content
...onse_fixtures/RepresentativeManagerTest.test_vote.content
+0
-1
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_votes.content
...nse_fixtures/RepresentativeManagerTest.test_votes.content
+0
-11
representatives_votes/tests/urls.py
representatives_votes/tests/urls.py
+11
-9
setup.py
setup.py
+1
-1
No files found.
representatives_votes/serializers.py
View file @
64804481
...
...
@@ -14,15 +14,19 @@ class VoteSerializer(serializers.HyperlinkedModelSerializer):
fields
=
(
'proposal'
,
'representative'
,
'representative_name'
,
'position'
)
extra_kwargs
=
{
'proposal'
:
{
'view_name'
:
'api-proposal-detail'
},
'representative'
:
{
'view_name'
:
'api-representative-detail'
}
}
class
ProposalSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
Meta
:
model
=
models
.
Proposal
fields
=
(
'id'
,
'dossier'
,
'title'
,
'description'
,
...
...
@@ -35,14 +39,18 @@ class ProposalSerializer(serializers.HyperlinkedModelSerializer):
'url'
,
)
extra_kwargs
=
{
'dossier'
:
{
'view_name'
:
'api-dossier-detail'
},
'url'
:
{
'view_name'
:
'api-proposal-detail'
}
}
class
ProposalDetailSerializer
(
ProposalSerializer
):
""" Proposal serializer that includes votes """
votes
=
VoteSerializer
(
many
=
True
)
class
Meta
:
model
=
models
.
Proposal
class
Meta
(
ProposalSerializer
.
Meta
):
fields
=
ProposalSerializer
.
Meta
.
fields
+
(
'votes'
,)
...
...
@@ -52,12 +60,18 @@ class DocumentSerializer(serializers.HyperlinkedModelSerializer):
class
Meta
:
model
=
models
.
Document
fields
=
(
'id'
,
'dossier'
,
'chamber'
,
'kind'
,
'link'
)
extra_kwargs
=
{
'dossier'
:
{
'view_name'
:
'api-dossier-detail'
},
'chamber'
:
{
'view_name'
:
'api-chamber-detail'
}
}
class
DossierSerializer
(
serializers
.
HyperlinkedModelSerializer
):
""" Base dossier serializer """
...
...
@@ -65,11 +79,15 @@ class DossierSerializer(serializers.HyperlinkedModelSerializer):
class
Meta
:
model
=
models
.
Dossier
fields
=
(
'id'
,
'url'
,
'title'
,
'reference'
,
'text'
,
'url'
,
)
extra_kwargs
=
{
'url'
:
{
'view_name'
:
'api-dossier-detail'
}
}
class
DossierDetailSerializer
(
DossierSerializer
):
...
...
@@ -80,6 +98,5 @@ class DossierDetailSerializer(DossierSerializer):
proposals
=
ProposalSerializer
(
many
=
True
)
documents
=
DocumentSerializer
(
many
=
True
)
class
Meta
:
model
=
models
.
Dossier
field
=
DossierSerializer
.
Meta
.
fields
+
(
'proposals'
,
'documents'
)
class
Meta
(
DossierSerializer
.
Meta
):
fields
=
DossierSerializer
.
Meta
.
fields
+
(
'proposals'
,
'documents'
)
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossier.content
View file @
64804481
{
"id": 1,
"url": "http://testserver/api/dossiers/1/",
"title": "Agenda for change: the future of EU development policy",
"reference": "2012/2002(INI)",
"text": "",
"proposals": [
{
"id": 1,
"dossier": "http://testserver/api/dossiers/1/",
"title": "A7-0234/2012 - Charles Goerens - § 31",
"description": "",
...
...
@@ -14,6 +19,7 @@
"url": "http://testserver/api/proposals/1/"
},
{
"id": 2,
"dossier": "http://testserver/api/dossiers/1/",
"title": "A7-0234/2012 - Charles Goerens - Résolution",
"description": "",
...
...
@@ -28,15 +34,11 @@
],
"documents": [
{
"id": 1,
"dossier": "http://testserver/api/dossiers/1/",
"chamber": "http://testserver/api/chambers/1/",
"kind": "procedure-file",
"link": "http://www.europarl.europa.eu/oeil/popups/ficheprocedure.do?reference=2012/2002(INI)"
}
],
"created": "2015-12-27T11:51:14.770000Z",
"updated": "2015-12-27T11:51:14.770000Z",
"title": "Agenda for change: the future of EU development policy",
"reference": "2012/2002(INI)",
"text": ""
]
}
\ No newline at end of file
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_dossiers.content
View file @
64804481
[
{
"id": 1,
"url": "http://testserver/api/dossiers/1/",
"title": "Agenda for change: the future of EU development policy",
"reference": "2012/2002(INI)",
"text": "",
"url": "http://testserver/api/dossiers/1/"
"text": ""
},
{
"id": 2,
"url": "http://testserver/api/dossiers/2/",
"title": "2016 general budget: all sections",
"reference": "2015/2132(BUD)",
"text": "",
"url": "http://testserver/api/dossiers/2/"
"text": ""
}
]
\ No newline at end of file
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposal.content
View file @
64804481
{
"id": 1,
"dossier": "http://testserver/api/dossiers/1/",
"title": "A7-0234/2012 - Charles Goerens - § 31",
"description": "",
...
...
@@ -13,13 +14,11 @@
{
"proposal": "http://testserver/api/proposals/1/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "abstain"
},
{
"proposal": "http://testserver/api/proposals/1/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "abstain"
}
]
...
...
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_proposals.content
View file @
64804481
[
{
"id": 1,
"dossier": "http://testserver/api/dossiers/1/",
"title": "A7-0234/2012 - Charles Goerens - § 31",
"description": "",
...
...
@@ -12,6 +13,7 @@
"url": "http://testserver/api/proposals/1/"
},
{
"id": 2,
"dossier": "http://testserver/api/dossiers/1/",
"title": "A7-0234/2012 - Charles Goerens - Résolution",
"description": "",
...
...
@@ -24,6 +26,7 @@
"url": "http://testserver/api/proposals/2/"
},
{
"id": 3,
"dossier": "http://testserver/api/dossiers/2/",
"title": "A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 4",
"description": "",
...
...
@@ -36,6 +39,7 @@
"url": "http://testserver/api/proposals/3/"
},
{
"id": 4,
"dossier": "http://testserver/api/dossiers/2/",
"title": "A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 29",
"description": "",
...
...
@@ -48,6 +52,7 @@
"url": "http://testserver/api/proposals/4/"
},
{
"id": 5,
"dossier": "http://testserver/api/dossiers/2/",
"title": "A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 31",
"description": "",
...
...
@@ -60,6 +65,7 @@
"url": "http://testserver/api/proposals/5/"
},
{
"id": 6,
"dossier": "http://testserver/api/dossiers/2/",
"title": "A8-0298/2015 - José Manuel Fernandes et Gérard Deprez - Am 30",
"description": "",
...
...
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_vote.content
View file @
64804481
{
"proposal": "http://testserver/api/proposals/1/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "abstain"
}
\ No newline at end of file
representatives_votes/tests/response_fixtures/RepresentativeManagerTest.test_votes.content
View file @
64804481
...
...
@@ -2,67 +2,56 @@
{
"proposal": "http://testserver/api/proposals/1/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "abstain"
},
{
"proposal": "http://testserver/api/proposals/1/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "abstain"
},
{
"proposal": "http://testserver/api/proposals/2/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "for"
},
{
"proposal": "http://testserver/api/proposals/2/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "for"
},
{
"proposal": "http://testserver/api/proposals/3/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "against"
},
{
"proposal": "http://testserver/api/proposals/3/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "against"
},
{
"proposal": "http://testserver/api/proposals/4/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "for"
},
{
"proposal": "http://testserver/api/proposals/4/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "against"
},
{
"proposal": "http://testserver/api/proposals/5/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "abstain"
},
{
"proposal": "http://testserver/api/proposals/5/",
"representative": "http://testserver/api/representatives/2/",
"representative_name": "",
"position": "against"
},
{
"proposal": "http://testserver/api/proposals/6/",
"representative": "http://testserver/api/representatives/1/",
"representative_name": "",
"position": "for"
}
]
\ No newline at end of file
representatives_votes/tests/urls.py
View file @
64804481
...
...
@@ -11,21 +11,23 @@ from representatives_votes.api import (
from
representatives.api
import
(
ChamberViewSet
,
ConstituencyViewSet
,
CountryViewSet
,
GroupViewSet
,
MandateViewSet
,
RepresentativeViewSet
,
)
router
=
routers
.
DefaultRouter
()
router
.
register
(
r
'chambers'
,
ChamberViewSet
)
router
.
register
(
r
'constituencies'
,
ConstituencyViewSet
)
router
.
register
(
r
'groups'
,
GroupViewSet
)
router
.
register
(
r
'mandates'
,
MandateViewSet
)
router
.
register
(
r
'representatives'
,
RepresentativeViewSet
)
router
.
register
(
r
'dossiers'
,
DossierViewSet
)
router
.
register
(
r
'proposals'
,
ProposalViewSet
)
router
.
register
(
r
'votes'
,
VoteViewSet
)
router
.
register
(
'countries'
,
CountryViewSet
,
'api-country'
)
router
.
register
(
'chambers'
,
ChamberViewSet
,
'api-chamber'
)
router
.
register
(
'constituencies'
,
ConstituencyViewSet
,
'api-constituency'
)
router
.
register
(
'groups'
,
GroupViewSet
,
'api-group'
)
router
.
register
(
'mandates'
,
MandateViewSet
,
'api-mandate'
)
router
.
register
(
'representatives'
,
RepresentativeViewSet
,
'api-representative'
)
router
.
register
(
'dossiers'
,
DossierViewSet
,
'api-dossier'
)
router
.
register
(
'proposals'
,
ProposalViewSet
,
'api-proposal'
)
router
.
register
(
'votes'
,
VoteViewSet
,
'api-vote'
)
urlpatterns
=
[
url
(
r
'api/'
,
include
(
router
.
urls
)),
url
(
'api/'
,
include
(
router
.
urls
)),
]
setup.py
View file @
64804481
...
...
@@ -13,7 +13,7 @@ setup(
keywords
=
'django government parliament votes'
,
install_requires
=
[
'django>1.8,<1.9'
,
'django-representatives>=0.0.3
2
'
,
'django-representatives>=0.0.3
3
'
,
'py-dateutil>=2,<3'
,
'ijson>=2,<3'
,
'pytz'
,
# Always use up-to-date TZ data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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