<commit_before># -*- coding:Utf-8 -*-
import json
from django.db import models
from django.db.models import Avg

from utils import clean_all_trends
from reps.models import Representative
from meps.models import MEP, Group, Country
from mps.models import MP
from memopol2.utils import color, reify
from django.core.urlresolvers import reverse

class Proposal(models.Model):
    id = models.CharField(max_length=63, primary_key=True)
    title = models.CharField(max_length=255, unique=True)
    ponderation = models.IntegerField(default=1)
    short_name = models.CharField(max_length=25, default=None, null=True)
    institution = models.CharField(max_length=63, choices=((u'EU', 'european parliament'), (u'FR', 'assemblée nationale française')))

    def get_absolute_url(self):
        if self.institution == "FR":
            return reverse("mps:vote", args=[self.id])
        return reverse("meps:vote", args=[self.id])

    @property
    def groups(self):
        return Group.objects.filter(groupmep__mep__score__proposal=self, groupmep__begin__lte=self.date, groupmep__end__gte=self.date).distinct().order_by('abbreviation')

    @property
    def countries(self):
        return Country.objects.filter(countrymep__mep__score__proposal=self, countrymep__begin__lte=self.date, countrymep__end__gte=self.date).distinct().order_by('code')

    @property
    def date(self):
        return self.recommendation_set.all()[0].datetime.date()

    def save(self, *args, **kwargs):
        # if I'm modifyed and not created
        if Proposal.objects.filter(id=self.id):
            clean_all_trends()
        super(Proposal, self).save(*args, **kwargs)

    @reify
    def meps(self):
        return MEP.objects.filter(score__proposal=self)

    @reify
    def mps(self):
        return MP.objects.filter(score__proposal=self)

    def __unicode__(self):
        return self.title
<commit_msg>[fix] correctly display mps on every vote<commit_after># -*- coding:Utf-8 -*-
import json
from django.db import models
from django.db.models import Avg

from utils import clean_all_trends
from reps.models import Representative
from meps.models import MEP, Group, Country
from mps.models import MP
from memopol2.utils import color, reify
from django.core.urlresolvers import reverse

class Proposal(models.Model):
    id = models.CharField(max_length=63, primary_key=True)
    title = models.CharField(max_length=255, unique=True)
    ponderation = models.IntegerField(default=1)
    short_name = models.CharField(max_length=25, default=None, null=True)
    institution = models.CharField(max_length=63, choices=((u'EU', 'european parliament'), (u'FR', 'assemblée nationale française')))

    def get_absolute_url(self):
        if self.institution == "FR":
            return reverse("mps:vote", args=[self.id])
        return reverse("meps:vote", args=[self.id])

    @property
    def groups(self):
        return Group.objects.filter(groupmep__mep__score__proposal=self, groupmep__begin__lte=self.date, groupmep__end__gte=self.date).distinct().order_by('abbreviation')

    @property
    def countries(self):
        return Country.objects.filter(countrymep__mep__score__proposal=self, countrymep__begin__lte=self.date, countrymep__end__gte=self.date).distinct().order_by('code')

    @property
    def date(self):
        return self.recommendation_set.all()[0].datetime.date()

    def save(self, *args, **kwargs):
        # if I'm modifyed and not created
        if Proposal.objects.filter(id=self.id):
            clean_all_trends()
        super(Proposal, self).save(*args, **kwargs)

    @reify
    def meps(self):
        return MEP.objects.filter(score__proposal=self)

    @reify
    def mps(self):
        return MP.objects.filter(vote__recommendation__proposal=self).distinct()

    def __unicode__(self):
        return self.title

{'fraction_non_alphanumeric': 0.11588541666666667, 'fraction_numerical': 0.0067708333333333336, 'mean_word_length': 4.094164456233422, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3057466', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1213, 'n_words': 250}