<commit_before>from django.db import models
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
# Project's apps

class CandidateList(models.Model):
    name = models.CharField(_('List Name'), max_length=80)
    ballot = models.CharField(_('Ballot'), max_length=4)
    candidates = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True, null=True, through='Candidate')
    number_of_seats = models.IntegerField(blank=True, null=True)
    surplus_partner = models.ForeignKey('self', blank=True, null=True,
                help_text=_('The list with which is the surplus votes partner'))
    img_url = models.URLField(_('Image URL'), blank=True)
    homepage_url = models.URLField(_('Homepage URL'), blank=True, null=True)
    youtube_url = models.URLField(_('YouTube URL'), blank=True, null=True)
    facebook_url = models.URLField(_('Facebook URL'), blank=True, null=True)
    platform = models.TextField(_('Platform'), blank=True, null=True)
    entity = models.ForeignKey('entities.Entity', blank=True, null=True)

    def save(self, *args, **kwargs):
        super(CandidateList, self).save()
        if self.surplus_partner:
            self.surplus_partner.surplus_partner = self

    @models.permalink
    def get_absolute_url(self):
        return ('candidate-list-detail', [self.id])

    def __unicode__(self):
        return self.name

    def get_candidates(self):
        return Candidate.objects.get_verified().filter(candidate_list=self)

    def can_edit(self, user):
        return user.is_authenticated() and \
            ((user.profile.is_editor and user.profile.locality == self.entity)\
            or (user.profile.is_candidate and user in self.candidates.all())\
            or user.is_superuser)


class Party(models.Model):
    name = models.CharField(max_length=64)
    accepts_memberships = models.BooleanField(default=True)

    def __unicode__(self):
        return self.name

    class Meta:
        verbose_name_plural = 'parties'

    def get_candidates(self):
        return Candidate.objects.get_verified().filter(party=self)

CANDIDATE_STATUS = (<commit_msg>fix bug when candidate tries to add new list<commit_after>from django.db import models
from django.conf import settings
from django.utils.translation import ugettext_lazy as _
# Project's apps

class CandidateList(models.Model):
    name = models.CharField(_('List Name'), max_length=80)
    ballot = models.CharField(_('Ballot'), max_length=4)
    candidates = models.ManyToManyField(settings.AUTH_USER_MODEL, blank=True, null=True, through='Candidate')
    number_of_seats = models.IntegerField(blank=True, null=True)
    surplus_partner = models.ForeignKey('self', blank=True, null=True,
                help_text=_('The list with which is the surplus votes partner'))
    img_url = models.URLField(_('Image URL'), blank=True)
    homepage_url = models.URLField(_('Homepage URL'), blank=True, null=True)
    youtube_url = models.URLField(_('YouTube URL'), blank=True, null=True)
    facebook_url = models.URLField(_('Facebook URL'), blank=True, null=True)
    platform = models.TextField(_('Platform'), blank=True, null=True)
    entity = models.ForeignKey('entities.Entity', blank=True, null=True)

    def save(self, *args, **kwargs):
        super(CandidateList, self).save()
        if self.surplus_partner:
            self.surplus_partner.surplus_partner = self

    @models.permalink
    def get_absolute_url(self):
        return ('candidate-list-detail', [self.id])

    def __unicode__(self):
        return self.name

    def get_candidates(self):
        return Candidate.objects.get_verified().filter(candidate_list=self)

    def can_edit(self, user):
        return user.is_authenticated() and \
            ((user.profile.is_editor and user.profile.locality == self.entity)\
            or (user.profile.is_candidate and self.candidate_set.exists() and user in self.candidates.all())\
            or user.is_superuser)


class Party(models.Model):
    name = models.CharField(max_length=64)
    accepts_memberships = models.BooleanField(default=True)

    def __unicode__(self):
        return self.name

    class Meta:
        verbose_name_plural = 'parties'

    def get_candidates(self):
        return Candidate.objects.get_verified().filter(party=self)

CANDIDATE_STATUS = (
{'fraction_non_alphanumeric': 0.11718569780853517, 'fraction_numerical': 0.002306805074971165, 'mean_word_length': 3.855543113101904, 'pattern_counts': {'":': 0, '<': 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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3346465', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1307, 'n_words': 276}