<commit_before>from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from uuslug import uuslug


@python_2_unicode_compatible
class Event(models.Model):
    """Events model.

    Mozillians can apply to attend these events.
    """
    name = models.CharField(max_length=255)
    slug = models.SlugField(blank=True, max_length=255)

    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = uuslug(self.full_name, instance=self)
        super(Event, self).save(*args, **kwargs)

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Application(models.Model):
    """Aplication model for Mozillians."""
    entry_id = models.IntegerField(default=0)
    number_of_events = models.IntegerField(default=1)
    event = models.ManyToManyField(Event, through='PreferredEvent')
    reasoning = models.TextField(blank=True, default='')
    contributions = models.TextField(default='', blank=True)
    learning_areas = models.TextField(default='', blank=True)
    recommendation_letter = models.CharField(max_length=255, default='',
                                             blank=True)
    ideas = models.TextField(blank=True, default='')
    commitments = models.TextField(blank=True, default='')
    functional_team = models.CharField(max_length=255, default='', blank=True)
    team_contact = models.CharField(max_length=255, default='', blank=True)
    participation_opportunities = models.TextField(default='', blank=True)
    tracking_communities = models.TextField(default='', blank=True)
    community_record = models.TextField(default='', blank=True)
    community_impact = models.TextField(default='', blank=True)
    other = models.TextField(default='', blank=True)
    date = models.DateTimeField(null=True, blank=True)
    apllication_complete = models.BooleanField(default=False)

    def __str__(self):
        return self.entry_id


@python_2_unicode_compatible
class PreferredEvent(models.Model):
    event = models.ForeignKey(Event)
    application = models.ForeignKey(Application)
    preferred = models.BooleanField(default=False)
    reason = models.TextField(blank=True, default='')

    def __str__(self):
        return self.event.name


@python_2_unicode_compatible
class MozillianGroup(models.Model):
    """Mozillians tracking groups."""
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['name']


@python_2_unicode_compatible
class MozillianProfile(models.Model):
    """Mozillians User Profile"""
    slug = models.SlugField(blank=True, max_length=100)
    full_name = models.CharField(max_length=255)
    email = models.EmailField(default='')
    city = models.CharField(max_length=50, default='', blank=True)
    country = models.CharField(max_length=50, default='')
    ircname = models.CharField(max_length=50, default='')
    tracking_groups = models.ManyToManyField(
        MozillianGroup, related_name='mozillians_tracking')
    avatar_url = models.URLField(max_length=400, default='')
    bio = models.TextField(blank=True, default='')
    mozillian_username = models.CharField(max_length=100, default='')
    application = models.ForeignKey(Application, blank=True, null=True,
                                    on_delete=models.SET_NULL,
                                    related_name='applications')

    def __str__(self):
        return self.full_name

    class Meta:
        ordering = ['country', 'full_name']

    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = uuslug(self.full_name, instance=self)
        super(MozillianProfile, self).save(*args, **kwargs)

    def get_next_entry(self):
        qs = MozillianProfile.objects.all()
        length = qs.count()
        for index, item in enumerate(qs):
            if (item == self) and (index <= length-2):
                return qs[index+1]
        return False

    def get_previous_entry(self):
        qs = MozillianProfile.objects.all()
        for index, item in enumerate(qs):
            if (item == self) and (index > 0):
                return qs[index-1]
        return False

    @property
    def positive(self):
        return self.votes.filter(vote=1).count()

    @property
    def stellar(self):
        return self.votes.filter(vote=2).count()

    @property
    def negative(self):
        return self.votes.filter(vote=-1).count()

    @property
    def skip(self):
        return self.votes.filter(vote=0).count()


class Vote(models.Model):
    """Vote relational model."""
    voter = models.ForeignKey(User, related_name='user_votes')
    nominee = models.ForeignKey(MozillianProfile, related_name='votes')
    vote = models.IntegerField(default=0, choices=((0, 'Skip'),
                                                   (1, 'Probably'),
                                                   (2, 'Definitely'),
                                                   (-1, 'No')))

    def __unicode__(self):
        return u'%s %s' % (self.voter, self.nominee.slug)
<commit_msg>Fix typo in Event model.<commit_after>from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible

from uuslug import uuslug


@python_2_unicode_compatible
class Event(models.Model):
    """Events model.

    Mozillians can apply to attend these events.
    """
    name = models.CharField(max_length=255)
    slug = models.SlugField(blank=True, max_length=255)

    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = uuslug(self.name, instance=self)
        super(Event, self).save(*args, **kwargs)

    def __str__(self):
        return self.name


@python_2_unicode_compatible
class Application(models.Model):
    """Aplication model for Mozillians."""
    entry_id = models.IntegerField(default=0)
    number_of_events = models.IntegerField(default=1)
    event = models.ManyToManyField(Event, through='PreferredEvent')
    reasoning = models.TextField(blank=True, default='')
    contributions = models.TextField(default='', blank=True)
    learning_areas = models.TextField(default='', blank=True)
    recommendation_letter = models.CharField(max_length=255, default='',
                                             blank=True)
    ideas = models.TextField(blank=True, default='')
    commitments = models.TextField(blank=True, default='')
    functional_team = models.CharField(max_length=255, default='', blank=True)
    team_contact = models.CharField(max_length=255, default='', blank=True)
    participation_opportunities = models.TextField(default='', blank=True)
    tracking_communities = models.TextField(default='', blank=True)
    community_record = models.TextField(default='', blank=True)
    community_impact = models.TextField(default='', blank=True)
    other = models.TextField(default='', blank=True)
    date = models.DateTimeField(null=True, blank=True)
    apllication_complete = models.BooleanField(default=False)

    def __str__(self):
        return self.entry_id


@python_2_unicode_compatible
class PreferredEvent(models.Model):
    event = models.ForeignKey(Event)
    application = models.ForeignKey(Application)
    preferred = models.BooleanField(default=False)
    reason = models.TextField(blank=True, default='')

    def __str__(self):
        return self.event.name


@python_2_unicode_compatible
class MozillianGroup(models.Model):
    """Mozillians tracking groups."""
    name = models.CharField(max_length=100)

    def __str__(self):
        return self.name

    class Meta:
        ordering = ['name']


@python_2_unicode_compatible
class MozillianProfile(models.Model):
    """Mozillians User Profile"""
    slug = models.SlugField(blank=True, max_length=100)
    full_name = models.CharField(max_length=255)
    email = models.EmailField(default='')
    city = models.CharField(max_length=50, default='', blank=True)
    country = models.CharField(max_length=50, default='')
    ircname = models.CharField(max_length=50, default='')
    tracking_groups = models.ManyToManyField(
        MozillianGroup, related_name='mozillians_tracking')
    avatar_url = models.URLField(max_length=400, default='')
    bio = models.TextField(blank=True, default='')
    mozillian_username = models.CharField(max_length=100, default='')
    application = models.ForeignKey(Application, blank=True, null=True,
                                    on_delete=models.SET_NULL,
                                    related_name='applications')

    def __str__(self):
        return self.full_name

    class Meta:
        ordering = ['country', 'full_name']

    def save(self, *args, **kwargs):
        if not self.pk:
            self.slug = uuslug(self.full_name, instance=self)
        super(MozillianProfile, self).save(*args, **kwargs)

    def get_next_entry(self):
        qs = MozillianProfile.objects.all()
        length = qs.count()
        for index, item in enumerate(qs):
            if (item == self) and (index <= length-2):
                return qs[index+1]
        return False

    def get_previous_entry(self):
        qs = MozillianProfile.objects.all()
        for index, item in enumerate(qs):
            if (item == self) and (index > 0):
                return qs[index-1]
        return False

    @property
    def positive(self):
        return self.votes.filter(vote=1).count()

    @property
    def stellar(self):
        return self.votes.filter(vote=2).count()

    @property
    def negative(self):
        return self.votes.filter(vote=-1).count()

    @property
    def skip(self):
        return self.votes.filter(vote=0).count()


class Vote(models.Model):
    """Vote relational model."""
    voter = models.ForeignKey(User, related_name='user_votes')
    nominee = models.ForeignKey(MozillianProfile, related_name='votes')
    vote = models.IntegerField(default=0, choices=((0, 'Skip'),
                                                   (1, 'Probably'),
                                                   (2, 'Definitely'),
                                                   (-1, 'No')))

    def __unicode__(self):
        return u'%s %s' % (self.voter, self.nominee.slug)

{'fraction_non_alphanumeric': 0.11992619926199262, 'fraction_numerical': 0.01107011070110701, 'mean_word_length': 3.0073929961089494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2614909', 'n_tokens_mistral': 3090, 'n_tokens_neox': 2953, 'n_words': 602}