<commit_before>from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from taggit.managers import TaggableManager
from taggit.models import TaggedItemBase

MAX_LENGTH_Q_SUBJECT = 80
MAX_LENGTH_Q_CONTENT = 255

MAX_LENGTH_A_SUBJECT = 80
MAX_LENGTH_A_CONTENT = 500

CANDIDATES_GROUP_NAME = "candidates"

class BaseModel(models.Model):
    created_at = models.DateTimeField(auto_now_add = True)
    updated_at = models.DateTimeField(auto_now = True)

    class Meta:
        abstract = True

class TaggedQuestion(TaggedItemBase):
    content_object = models.ForeignKey("Question")

class Question(BaseModel):
    author = models.ForeignKey(User, related_name="questions", verbose_name=_("author"))
    subject = models.CharField(_("subject"), max_length=MAX_LENGTH_Q_SUBJECT,
        help_text=_("Please enter a subject in no more than %s letters") %  MAX_LENGTH_Q_SUBJECT)
    content = models.TextField(_("content"), max_length=MAX_LENGTH_Q_CONTENT,
        help_text=_("Please enter your content in no more than %s letters") %  MAX_LENGTH_Q_CONTENT)
    rating = models.IntegerField(_("rating"), default=1)
    tags = TaggableManager(through=TaggedQuestion)

    def __unicode__(self):
        return self.subject

    def can_answer(self, user):
        ''' Can a given user answer self? '''
        return user.has_perm('qa.add_answer')

    def get_absolute_url(self):
        return reverse('question-details', kwargs= {'q_id': self.id})

class Answer(BaseModel):
    author = models.ForeignKey(User, related_name="answers", verbose_name=_("author"))
    content = models.TextField(_("content"), max_length=MAX_LENGTH_A_CONTENT, 
        help_text=_("Please enter an answer in no more than %s letters") %  MAX_LENGTH_A_CONTENT)
    rating = models.IntegerField(_("rating"), default=0)
    question = models.ForeignKey(Question, related_name="answers", verbose_name=_("question"))

    def __unicode__(self):
        return "%s: %s" % (self.author, self.content[:30])


class QuestionUpvote(BaseModel):
    question = models.ForeignKey(Question, related_name="upvotes")
    user = models.ForeignKey(User, related_name="upvotes")
<commit_msg>PEP-8<commit_after>from django.db import models
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
from django.core.urlresolvers import reverse
from taggit.managers import TaggableManager
from taggit.models import TaggedItemBase

MAX_LENGTH_Q_SUBJECT = 80
MAX_LENGTH_Q_CONTENT = 255

MAX_LENGTH_A_SUBJECT = 80
MAX_LENGTH_A_CONTENT = 500

CANDIDATES_GROUP_NAME = "candidates"


class BaseModel(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


class TaggedQuestion(TaggedItemBase):
    content_object = models.ForeignKey("Question")


class Question(BaseModel):
    author = models.ForeignKey(User, related_name="questions", verbose_name=_("author"))
    subject = models.CharField(_("subject"), max_length=MAX_LENGTH_Q_SUBJECT,
        help_text=_("Please enter a subject in no more than %s letters") % MAX_LENGTH_Q_SUBJECT)
    content = models.TextField(_("content"), max_length=MAX_LENGTH_Q_CONTENT,
        help_text=_("Please enter your content in no more than %s letters") % MAX_LENGTH_Q_CONTENT)
    rating = models.IntegerField(_("rating"), default=1)
    tags = TaggableManager(through=TaggedQuestion)

    def __unicode__(self):
        return self.subject

    def can_answer(self, user):
        ''' Can a given user answer self? '''
        return user.has_perm('qa.add_answer')

    def get_absolute_url(self):
        return reverse('question-details', kwargs={'q_id': self.id})


class Answer(BaseModel):
    author = models.ForeignKey(User, related_name="answers", verbose_name=_("author"))
    content = models.TextField(_("content"), max_length=MAX_LENGTH_A_CONTENT,
        help_text=_("Please enter an answer in no more than %s letters") % MAX_LENGTH_A_CONTENT)
    rating = models.IntegerField(_("rating"), default=0)
    question = models.ForeignKey(Question, related_name="answers", verbose_name=_("question"))

    def __unicode__(self):
        return "%s: %s" % (self.author, self.content[:30])


class QuestionUpvote(BaseModel):
    question = models.ForeignKey(Question, related_name="upvotes")
    user = models.ForeignKey(User, related_name="upvotes")

{'fraction_non_alphanumeric': 0.10859427048634245, 'fraction_numerical': 0.006440151010437486, 'mean_word_length': 4.9498018494055485, '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': '6227966', 'n_tokens_mistral': 1409, 'n_tokens_neox': 1364, 'n_words': 305}