from django.db import models
from meps.models import MEP

class Proposal(models.Model):
    id = models.CharField(max_length=63, primary_key=True)
    title = models.CharField(max_length=255, unique=True)

class SubProposal(models.Model):
    datetime = models.DateTimeField()
    subject = models.CharField(max_length=255)
    part = models.CharField(max_length=255)
    description = models.CharField(max_length=511)
    weight = models.IntegerField(null=True)
    vote = models.ForeignKey(Proposal)
    recommendation = models.CharField(max_length=15, choices=((u'against', u'against'), (u'for', u'for')), null=True)

class Vote(models.Model):
    choice = models.CharField(max_length=15, choices=((u'for', u'for'), (u'against', u'against'), (u'abstention', u'abstention')))
    name = models.CharField(max_length=127)
    mep = models.ForeignKey(MEP)

from django.db import models
from meps.models import MEP

class Proposal(models.Model):
    id = models.CharField(max_length=63, primary_key=True)
    title = models.CharField(max_length=255, unique=True)

class SubProposal(models.Model):
    datetime = models.DateTimeField()
    subject = models.CharField(max_length=255)
    part = models.CharField(max_length=255)
    description = models.CharField(max_length=511)
    weight = models.IntegerField(null=True)
    vote = models.ForeignKey(Proposal)
    recommendation = models.CharField(max_length=15, choices=((u'against', u'against'), (u'for', u'for')), null=True)

class Vote(models.Model):
    choice = models.CharField(max_length=15, choices=((u'for', u'for'), (u'against', u'against'), (u'abstention', u'abstention')))
    name = models.CharField(max_length=127)
    sub_proposal = models.ForeignKey(SubProposal)
    mep = models.ForeignKey(MEP)

Add a link between vote and subproposal
[enh] Add a link between vote and subproposal

  from django.db import models
  from meps.models import MEP
  
  class Proposal(models.Model):
      id = models.CharField(max_length=63, primary_key=True)
      title = models.CharField(max_length=255, unique=True)
  
  class SubProposal(models.Model):
      datetime = models.DateTimeField()
      subject = models.CharField(max_length=255)
      part = models.CharField(max_length=255)
      description = models.CharField(max_length=511)
      weight = models.IntegerField(null=True)
      vote = models.ForeignKey(Proposal)
      recommendation = models.CharField(max_length=15, choices=((u'against', u'against'), (u'for', u'for')), null=True)
  
  class Vote(models.Model):
      choice = models.CharField(max_length=15, choices=((u'for', u'for'), (u'against', u'against'), (u'abstention', u'abstention')))
      name = models.CharField(max_length=127)
+     sub_proposal = models.ForeignKey(SubProposal)
      mep = models.ForeignKey(MEP)
  
Add a link between vote and subproposal
## Code Before:
from django.db import models
from meps.models import MEP

class Proposal(models.Model):
    id = models.CharField(max_length=63, primary_key=True)
    title = models.CharField(max_length=255, unique=True)

class SubProposal(models.Model):
    datetime = models.DateTimeField()
    subject = models.CharField(max_length=255)
    part = models.CharField(max_length=255)
    description = models.CharField(max_length=511)
    weight = models.IntegerField(null=True)
    vote = models.ForeignKey(Proposal)
    recommendation = models.CharField(max_length=15, choices=((u'against', u'against'), (u'for', u'for')), null=True)

class Vote(models.Model):
    choice = models.CharField(max_length=15, choices=((u'for', u'for'), (u'against', u'against'), (u'abstention', u'abstention')))
    name = models.CharField(max_length=127)
    mep = models.ForeignKey(MEP)

## Instruction:
Add a link between vote and subproposal
## Code After:
from django.db import models
from meps.models import MEP

class Proposal(models.Model):
    id = models.CharField(max_length=63, primary_key=True)
    title = models.CharField(max_length=255, unique=True)

class SubProposal(models.Model):
    datetime = models.DateTimeField()
    subject = models.CharField(max_length=255)
    part = models.CharField(max_length=255)
    description = models.CharField(max_length=511)
    weight = models.IntegerField(null=True)
    vote = models.ForeignKey(Proposal)
    recommendation = models.CharField(max_length=15, choices=((u'against', u'against'), (u'for', u'for')), null=True)

class Vote(models.Model):
    choice = models.CharField(max_length=15, choices=((u'for', u'for'), (u'against', u'against'), (u'abstention', u'abstention')))
    name = models.CharField(max_length=127)
    sub_proposal = models.ForeignKey(SubProposal)
    mep = models.ForeignKey(MEP)
