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


class BaseMixin(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True


class OrderedMixin(models.Model):
    display_order = models.IntegerField(unique=True)

    class Meta:
        abstract = True

class BaseHumanMixin(BaseMixin, OrderedMixin):
    class Meta:
        abstract = True


class HumanGroup(BaseHumanMixin):
    label = models.CharField(max_length=100)

    def __unicode__(self):
        return self.label

class HandleType(BaseMixin):
    type = models.CharField(max_length=100)

    # Use standard Django template language. You must load tags if you are going to use them.
    template = models.TextField(blank=True)

    def __unicode__(self):
        return self.type

class Handle(BaseMixin):
    type = models.ForeignKey(HandleType)
    handle = models.CharField(max_length=100)

    def __unicode__(self):
        return self.handle

    def render_handle(self):
        """ This is where we should hook the template system """
        pass


class Human(BaseHumanMixin):
    role = models.CharField(max_length=100)
    group = models.ForeignKey(HumanGroup)

    name = models.CharField(max_length=255, blank=True)
    user = models.OneToOneField(User, related_name='human')
    handles = models.ManyToManyField(Handle)

    def __unicode__(self):
        if self.user:
            return self.user.get_full_name() or self.user.username
        elif self.name:
            return self.name
        else:
            return 'anonymous'

    def render_handles(self):
        pass


class Snippet(BaseHumanMixin):
    """ Used to hold chunks of non-HTML text to be displayed. """
    text = models.TextField()

    def __unicode__(self):
        return self.text<commit_msg>Clean up models, add title field to snippets.<commit_after>from django.contrib.auth.models import User
from django.db import models


# Model mixins
class BaseMixin(models.Model):
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    class Meta:
        abstract = True
        ordering = ['modified', 'created',]


class OrderedMixin(models.Model):
    display_order = models.IntegerField(unique=True)

    class Meta:
        abstract = True
        ordering = ['display_order', ]

class BaseHumanMixin(BaseMixin, OrderedMixin):
    class Meta:
        abstract = True


# Begin concrete models
class HumanGroup(BaseHumanMixin):
    label = models.CharField(max_length=100)

    def __unicode__(self):
        return self.label


class HandleType(BaseMixin):
    type = models.CharField(max_length=100)

    # Use standard Django template language. You must load tags if you are going to use them.
    template = models.TextField(blank=True)

    def __unicode__(self):
        return self.type


class Handle(BaseMixin):
    type = models.ForeignKey(HandleType)
    handle = models.CharField(max_length=100)

    def __unicode__(self):
        return self.handle

    def render_handle(self):
        """ This is where we should hook the template system """
        pass


class Human(BaseHumanMixin):
    role = models.CharField(max_length=100)
    group = models.ForeignKey(HumanGroup)

    # Humans can be linked to Users or stand on their own
    name = models.CharField(max_length=255, blank=True)
    user = models.OneToOneField(User, related_name='human', blank=True, null=True)
    handles = models.ManyToManyField(Handle)

    def __unicode__(self):
        """
        If a User is linked, use that, else default to name field, else is anonymous.
        """
        if self.user:
            return self.user.get_full_name() or self.user.username
        elif self.name:
            return self.name
        else:
            return 'anonymous'

    def render_handles(self):
        """ Grab all of the handles, render them, and return them as a list. """
        pass


class Snippet(BaseHumanMixin):
    """ Used to hold chunks of non-HTML text to be displayed. """

    title = models.CharField(max_length=100)
    text = models.TextField()

    class Meta:
        ordering = ['display_order',]

    def __unicode__(self):
        return self.title
{'fraction_non_alphanumeric': 0.09012974976830398, 'fraction_numerical': 0.007645968489341983, 'mean_word_length': 3.000926784059314, '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': '4776383', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1217, 'n_words': 341}