Commit ab657755 authored by Nicolas Joyard's avatar Nicolas Joyard

Test committee vote imports

parent 4085501d
......@@ -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='Committee vote'
kind='committee-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)
......
[
{
"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
}
]
......@@ -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"
}
]
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