<commit_before>from django.contrib.gis.db import models
from geo.models import Municipality

class Election(models.Model):
    TYPE_CHOICES = (
        ('pres', 'presidential'),
        ('parl', 'parliamentary'),
        ('muni', 'municipal'),
        ('euro', 'European Union'),
    )
    type = models.CharField(max_length=4, choices=TYPE_CHOICES)
    date = models.DateField()
    year = models.PositiveIntegerField()
    # Presidential elections can have two rounds
    round = models.PositiveSmallIntegerField()

class Party(models.Model):
    name = models.CharField(max_length=80)
    code = models.CharField(max_length=8)
    abbrev = models.CharField(max_length=8)

    def __unicode__(self):
        return "%s" % (self.abbrev)

# For party names in other languages
class PartyName(models.Model):
    party = models.ForeignKey(Party)
    language = models.CharField(max_length=8)
    name = models.CharField(max_length=80)

class Person(models.Model):
    GENDERS = (
        ('M', 'Male'),
        ('F', 'Female')
    )
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=50, db_index=True)
    gender = models.CharField(max_length=1, null=True, choices=GENDERS)
    party = models.ForeignKey(Party, null=True)
    municipality = models.ForeignKey(Municipality, db_index=True)

    def __unicode__(self):
        return "%s %s" % (self.first_name, self.last_name)

class Candidate(models.Model):
    person = models.ForeignKey(Person)
    number = models.PositiveIntegerField()
    profession = models.CharField(max_length=100)
    party = models.ForeignKey(Party, null=True)
    party_code = models.CharField(max_length=8)
    election = models.ForeignKey(Election, db_index=True)
    municipality = models.ForeignKey(Municipality, null=True, db_index=True)

class VotingDistrict(models.Model):
    municipality = models.ForeignKey(Municipality)
    # Lists the elections for which this district is valid
    elections = models.ManyToManyField(Election)
    origin_id = models.CharField(max_length=10)
    name = models.CharField(max_length=50)
    borders = models.MultiPolygonField(null=True)

    class Meta:
        unique_together = (('municipality', 'origin_id'),)

class MunicipalityCommittee(models.Model):
    municipality = models.ForeignKey(Municipality)
    name = models.CharField(max_length=100)

class MunicipalityTrustee(models.Model):
    election = models.ForeignKey(Election)
    person = models.ForeignKey(Person)
    committee = models.ForeignKey(MunicipalityCommittee)
    role = models.CharField(max_length=30)
    begin = models.DateField()
    end = models.DateField()


from social.models import Feed

class CandidateFeed(Feed):
    candidate = models.ForeignKey(Candidate)<commit_msg>Added models for expenses<commit_after>from django.contrib.gis.db import models
from geo.models import Municipality

class Election(models.Model):
    TYPE_CHOICES = (
        ('pres', 'presidential'),
        ('parl', 'parliamentary'),
        ('muni', 'municipal'),
        ('euro', 'European Union'),
    )
    type = models.CharField(max_length=4, choices=TYPE_CHOICES)
    date = models.DateField()
    year = models.PositiveIntegerField()
    # Presidential elections can have two rounds
    round = models.PositiveSmallIntegerField()

class Party(models.Model):
    name = models.CharField(max_length=80)
    code = models.CharField(max_length=8)
    abbrev = models.CharField(max_length=8)

    def __unicode__(self):
        return "%s" % (self.abbrev)

# For party names in other languages
class PartyName(models.Model):
    party = models.ForeignKey(Party)
    language = models.CharField(max_length=8)
    name = models.CharField(max_length=80)

class Person(models.Model):
    GENDERS = (
        ('M', 'Male'),
        ('F', 'Female')
    )
    first_name = models.CharField(max_length=30)
    last_name = models.CharField(max_length=50, db_index=True)
    gender = models.CharField(max_length=1, null=True, choices=GENDERS)
    party = models.ForeignKey(Party, null=True)
    municipality = models.ForeignKey(Municipality, db_index=True)

    def __unicode__(self):
        return "%s %s" % (self.first_name, self.last_name)

class Candidate(models.Model):
    person = models.ForeignKey(Person)
    number = models.PositiveIntegerField()
    profession = models.CharField(max_length=100)
    party = models.ForeignKey(Party, null=True)
    party_code = models.CharField(max_length=8)
    election = models.ForeignKey(Election, db_index=True)
    municipality = models.ForeignKey(Municipality, null=True, db_index=True)

class VotingDistrict(models.Model):
    municipality = models.ForeignKey(Municipality)
    # Lists the elections for which this district is valid
    elections = models.ManyToManyField(Election)
    origin_id = models.CharField(max_length=10)
    name = models.CharField(max_length=50)
    borders = models.MultiPolygonField(null=True)

    class Meta:
        unique_together = (('municipality', 'origin_id'),)

class MunicipalityCommittee(models.Model):
    municipality = models.ForeignKey(Municipality)
    name = models.CharField(max_length=100)

class MunicipalityTrustee(models.Model):
    election = models.ForeignKey(Election)
    person = models.ForeignKey(Person)
    committee = models.ForeignKey(MunicipalityCommittee)
    role = models.CharField(max_length=30)
    begin = models.DateField()
    end = models.DateField()


from social.models import Feed

class CandidateFeed(Feed):
    candidate = models.ForeignKey(Candidate)
    
class ExpenseType(models.Model):
    '''Models different types of expenses a campaign can have.
    '''
    description = models.CharField(max_lenght=100)
    
class Expenses(models.Model):
    '''Models different election campaign expenses.
    '''

    candidate = models.ForeignKey(Candidate)
    expense_type = models.ForeignKey(ExpenseType)
    
{'fraction_non_alphanumeric': 0.11244911804613297, 'fraction_numerical': 0.009328358208955223, 'mean_word_length': 4.15472027972028, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3591118', 'n_tokens_mistral': 1864, 'n_tokens_neox': 1805, 'n_words': 356}