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
luxcem
memopol
Commits
ab657755
Commit
ab657755
authored
Oct 11, 2016
by
Nicolas Joyard
Browse files
Test committee vote imports
parent
4085501d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/representatives_votes/contrib/parltrack/import_votes.py
View file @
ab657755
...
...
@@ -65,7 +65,7 @@ class Command(object):
if
'committee'
in
vote_data
:
return
self
.
parse_committee_vote_data
(
vote
_data
=
vote_data
,
proposal
_data
=
vote_data
,
dossier_pk
=
dossier_pk
)
else
:
...
...
@@ -93,7 +93,8 @@ class Command(object):
u
'Looking for votes in proposal {}'
.
format
(
proposal
.
title
))
for
position
in
(
'For'
,
'Abstain'
,
'Against'
):
for
group_vote_data
in
data
.
get
(
position
,
{}).
get
(
'groups'
,
{}):
for
group_vote_data
in
data
.
get
(
position_map
[
position
],
{}).
get
(
'groups'
,
{}):
for
vote_data
in
group_vote_data
[
'votes'
]:
if
not
isinstance
(
vote_data
,
dict
):
logger
.
error
(
'Skipping vote data %s for proposal %s'
,
...
...
@@ -123,12 +124,12 @@ class Command(object):
if
changed
:
vote
.
save
()
logger
.
debug
(
'Save vote %s for MEP %s on %s #%s to %s'
,
vote
.
pk
,
representative_pk
,
data
[
'title'
],
proposal
.
pk
,
position
)
vote
.
pk
,
representative_pk
,
proposal
.
title
,
proposal
.
pk
,
position
)
@
transaction
.
atomic
def
parse_committee_vote_data
(
self
,
proposal_data
,
dossier_pk
):
title
=
u
'
{}
vote on
{}
'
%
(
proposal_data
[
'committee'
],
title
=
u
'
%s
vote on
%s
'
%
(
proposal_data
[
'committee'
],
proposal_data
[
'doc'
])
changed
=
False
...
...
@@ -147,7 +148,7 @@ class Command(object):
data_map
=
dict
(
datetime
=
_parse_date
(
proposal_data
[
'ts'
]),
reference
=
ref
,
kind
=
'
C
ommittee
vote'
kind
=
'
c
ommittee
-
vote'
)
position_map
=
{
...
...
@@ -170,7 +171,7 @@ class Command(object):
if
self
.
should_skip
(
proposal_data
):
logger
.
debug
(
u
'Skipping votes for dossier %s'
,
proposal_data
.
get
(
'epref'
,
proposal_data
[
'
title
'
]
))
'epref'
,
title
))
return
self
.
parse_proposal_votes
(
proposal
,
proposal_data
,
position_map
)
...
...
src/representatives_votes/contrib/parltrack/tests/votes_expected.json
View file @
ab657755
[
{
"fields"
:
{
"total_for"
:
1
,
"description"
:
""
,
"reference"
:
"TEST-COM-VOTE"
,
"title"
:
"LIBE vote on Test Committee Vote"
,
"dossier"
:
[
"2012/2002(INI)"
],
"kind"
:
"committee-vote"
,
"datetime"
:
"2012-10-23T16:31:10Z"
,
"total_against"
:
1
,
"total_abstain"
:
0
},
"model"
:
"representatives_votes.proposal"
},
{
"fields"
:
{
"representative_name"
:
""
,
...
...
@@ -163,5 +179,35 @@
},
"model"
:
"representatives_votes.vote"
,
"pk"
:
11
},
{
"fields"
:
{
"representative_name"
:
""
,
"position"
:
"for"
,
"proposal"
:
[
"LIBE vote on Test Committee Vote"
,
"2012/2002(INI)"
],
"representative"
:
[
"hubert-pirker-1948-10-03"
]
},
"model"
:
"representatives_votes.vote"
,
"pk"
:
12
},
{
"fields"
:
{
"representative_name"
:
""
,
"position"
:
"against"
,
"proposal"
:
[
"LIBE vote on Test Committee Vote"
,
"2012/2002(INI)"
],
"representative"
:
[
"olle-ludvigsson-1948-10-28"
]
},
"model"
:
"representatives_votes.vote"
,
"pk"
:
13
}
]
src/representatives_votes/contrib/parltrack/tests/votes_fixture.json
View file @
ab657755
...
...
@@ -281,5 +281,45 @@
"ts"
:
"2015-10-28T13:01:09"
,
"url"
:
"http://www.europarl.europa.eu/RegData/seance_pleniere/proces_verbal/2015/10-28/votes_nominaux/xml/P8_PV(2015)10-28(RCV)_XC.xml"
,
"voteid"
:
"59151"
},
{
"url"
:
"http://www.europarl.europa.eu/sides/getDoc.do?type=REPORT&mode=XML&reference=TEST-COM-VOTE&language=EN"
,
"doc"
:
"Test Committee Vote"
,
"+"
:
{
"groups"
:
[
{
"group"
:
"PPE"
,
"votes"
:
[
{
"ep_id"
:
2307
,
"name"
:
"Pirker"
}
]
}
],
"total"
:
"1"
},
"epref"
:
"2012/2002(INI)"
,
"-"
:
{
"groups"
:
[
{
"group"
:
"PPE"
,
"votes"
:
[
{
"ep_id"
:
96673
,
"name"
:
"Ludvigsson"
}
]
}
],
"total"
:
"1"
},
"ts"
:
"2012-10-23T18:31:10"
,
"0"
:
{
"total"
:
0
,
"groups"
:
[]
},
"committee"
:
"LIBE"
,
"_id"
:
"56617c15edd52ed712fc7901"
}
]
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