Skip to content
Extraits de code Groupes Projets
Valider 0b22e126 rédigé par Arnaud Fabre's avatar Arnaud Fabre
Parcourir les fichiers

updates representatives_votes format

parent 270c78a3
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
{
"Dossier": {
"dossier": {
"title": "", // Dossier title, eg "2011/0167(NLE) EU/Australia, Canada, Japan, Korea, Mexico, Morocco, New Zealand, Singapore, Switzerland and United States Anti-Counterfeiting Trade Agreement (ACTA)"
"reference": "", // Dossier reference, eg "2011/0167(NLE)"
"text": "", // Descriptipn
"Proposals": [{
"proposals": [{
"title": "", // eg A7-0204/2012 - David Martin - Request for referral back to committee
"reference", "", // eg A7-0204/2012
"reference": "", // eg A7-0204/2012
"description": "",
"kind": "",
"date": "", // timestamp
"votes": [{
......
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('representatives_votes', '0002_auto_20150511_1209'),
]
operations = [
migrations.AddField(
model_name='proposal',
name='kind',
field=models.CharField(max_length=200, null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='proposal',
name='reference',
field=models.CharField(max_length=200, null=True),
preserve_default=True,
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('representatives_votes', '0003_auto_20150513_0936'),
]
operations = [
migrations.RenameField(
model_name='vote',
old_name='representative_slug',
new_name='representative_name',
),
]
......@@ -14,9 +14,9 @@ class Proposal(models.Model):
dossier = models.ForeignKey(Dossier)
title = models.CharField(max_length=500)
description = models.TextField()
reference = models.CharField(max_length=200)
reference = models.CharField(max_length=200, null=True)
datetime = models.DateTimeField()
kind = models.CharField(max_length=200, null=True)
total_abstain = models.IntegerField()
total_against = models.IntegerField()
total_for = models.IntegerField()
......@@ -31,7 +31,8 @@ class Vote(models.Model):
proposal = models.ForeignKey(Proposal)
representative_slug = models.CharField(max_length=200, blank=True, null=True)
# There are two representative fields for flexibility,
representative_name = models.CharField(max_length=200, blank=True, null=True)
representative_remote_id = models.CharField(max_length=200, blank=True, null=True)
position = models.CharField(max_length=10, choices=VOTECHOICES)
from .models import Dossier
def export_all_dossiers():
return [export_a_dossier(dossier) for dossier in Dossier.objects.all()]
def export_a_dossier(dossier):
ret = {'dossier': {
'title': dossier.title,
'reference': dossier.reference,
'text': dossier.text
}}
ret['proposals'] = [export_a_proposal(proposal) for proposal in dossier.proposal_set.all()]
return ret
def export_a_proposal(proposal):
ret = {
'title': proposal.title,
'reference': proposal.reference,
'description': proposal.description,
'date': proposal.datetime.isoformat(),
'total_abstain': proposal.total_abstain,
'total_against': proposal.total_against,
'total_for': proposal.total_for
}
ret['votes'] = [export_a_vote(vote) for vote in proposal.vote_set.all()]
return ret
def export_a_vote(vote):
return {
'representative': vote.representative_remote_id,
'postion': vote.position
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter