Commit 42eb80b1 authored by luxcem's avatar luxcem Committed by Arnaud Fabre

new vote model

parent 1c99e625
*.sqlite3
*.sqlite
*.pyc
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Dossier',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=500)),
('reference', models.CharField(max_length=200)),
('text', models.TextField()),
('link', models.URLField()),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Proposal',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('title', models.CharField(max_length=500)),
('description', models.TextField()),
('reference', models.CharField(max_length=200)),
('datetime', models.DateTimeField()),
('dossier', models.ForeignKey(to='representatives_votes.Dossier')),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='Vote',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('representative_slug', models.CharField(max_length=200, null=True, blank=True)),
('representative_remote_id', models.CharField(max_length=200, null=True, blank=True)),
('position', models.CharField(max_length=10, choices=[(b'abstain', b'abstain'), (b'for', b'for'), (b'against', b'against')])),
('proposal', models.ForeignKey(to='representatives_votes.Proposal')),
],
options={
},
bases=(models.Model,),
),
]
# -*- coding:Utf-8 -*- # coding: utf-8
from django.db import models from django.db import models
from parltrack_meps.models import MEP
class Proposal(models.Model):
title = models.TextField(null=True)
code_name = models.CharField(max_length=255, unique=True)
date = models.DateField(default=None, null=True, blank=True)
class Dossier(models.Model):
title = models.CharField(max_length=500)
reference = models.CharField(max_length=200)
text = models.TextField()
link = models.URLField()
def __unicode__(self):
return "%s [%s]" % (self.title if self.title else "no title", self.code_name)
class Meta: class Proposal(models.Model):
ordering = ('-_date', ) dossier = models.ForeignKey(Dossier)
title = models.CharField(max_length=500)
description = models.TextField()
class ProposalPart(models.Model): reference = models.CharField(max_length=200)
datetime = models.DateTimeField() datetime = models.DateTimeField()
subject = models.CharField(max_length=255)
part = models.CharField(max_length=255)
description = models.CharField(max_length=511)
proposal = models.ForeignKey(Proposal)
def __unicode__(self):
return self.subject
class MetaClass:
ordering = ['datetime']
class Vote(models.Model): class Vote(models.Model):
choice = models.CharField(max_length=15, choices=((u'for', u'for'), (u'against', u'against'), (u'abstention', u'abstention'), (u'absent', u'absent'))) VOTECHOICES = (
name = models.CharField(max_length=127) ('abstain', 'abstain'),
proposal_part = models.ForeignKey(ProposalPart) ('for', 'for'),
mep = models.ForeignKey(MEP, null=True) ('against', 'against')
)
proposal = models.ForeignKey(Proposal)
class Meta: representative_slug = models.CharField(max_length=200, blank=True, null=True)
ordering = ["choice"] representative_remote_id = models.CharField(max_length=200, blank=True, null=True)
unique_together = ("proposal_part", "mep")
def __unicode__(self): position = models.CharField(max_length=10, choices=VOTECHOICES)
return '%s (%s)' % (self.name, self.choice)
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