<commit_before>from django.db import models
from django.db.models.query import QuerySet
from django.core.urlresolvers import reverse

from mptt.models import MPTTModel, TreeForeignKey

from model_utils import Choices
from model_utils.managers import PassThroughManager
from model_utils.fields import StatusField

from tinymce import models as tinymce_models


class SiteEntityQuerySet(QuerySet):
    def live(self):
        return self.filter(status=SiteEntity.STATUS.live)


class SiteEntity(models.Model):
    STATUS = Choices(
        ('draft', 'Draft'),
        ('live', 'Live'),
    )

    title = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    order = models.IntegerField(null=True, blank=True)
    status = StatusField()

    objects = PassThroughManager.for_queryset_class(SiteEntityQuerySet)()

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['order', 'title']


class Displayable(SiteEntity):
    body = tinymce_models.HTMLField()


class Page(MPTTModel, Displayable):
    template_override = models.CharField(max_length=255, null=True,
        blank=True)

    parent = TreeForeignKey('self', null=True, blank=True,
        related_name='children')

    objects = PassThroughManager.for_queryset_class(SiteEntityQuerySet)()

    @property
    def url(self):
        if self.is_root_node():
            return reverse('suave:page')

        crumbs = []
        for ancestor in self.get_ancestors():
            if ancestor.is_root_node():
                continue
            crumbs.append(ancestor.slug)
        crumbs.append(self.slug)
        return reverse('suave:page', kwargs=dict(
            url='/'.join(crumbs)))

    class Meta:
        ordering = ['order']


class Attachment(SiteEntity):
    pass
<commit_msg> added str to sitentity<commit_after>from django.db import models
from django.db.models.query import QuerySet
from django.core.urlresolvers import reverse

from mptt.models import MPTTModel, TreeForeignKey

from model_utils import Choices
from model_utils.managers import PassThroughManager
from model_utils.fields import StatusField

from tinymce import models as tinymce_models


class SiteEntityQuerySet(QuerySet):
    def live(self):
        return self.filter(status=SiteEntity.STATUS.live)


class SiteEntity(models.Model):
    STATUS = Choices(
        ('draft', 'Draft'),
        ('live', 'Live'),
    )

    title = models.CharField(max_length=255)
    slug = models.SlugField(max_length=255)
    order = models.IntegerField(null=True, blank=True)
    status = StatusField()

    objects = PassThroughManager.for_queryset_class(SiteEntityQuerySet)()

    def __str__(self):
        return self.title

    def __unicode__(self):
        return self.title

    class Meta:
        ordering = ['order', 'title']


class Displayable(SiteEntity):
    body = tinymce_models.HTMLField()


class Page(MPTTModel, Displayable):
    template_override = models.CharField(max_length=255, null=True,
        blank=True)

    parent = TreeForeignKey('self', null=True, blank=True,
        related_name='children')

    objects = PassThroughManager.for_queryset_class(SiteEntityQuerySet)()

    @property
    def url(self):
        if self.is_root_node():
            return reverse('suave:page')

        crumbs = []
        for ancestor in self.get_ancestors():
            if ancestor.is_root_node():
                continue
            crumbs.append(ancestor.slug)
        crumbs.append(self.slug)
        return reverse('suave:page', kwargs=dict(
            url='/'.join(crumbs)))

    class Meta:
        ordering = ['order']


class Attachment(SiteEntity):
    pass

{'fraction_non_alphanumeric': 0.10065288356909684, 'fraction_numerical': 0.004896626768226333, 'mean_word_length': 3.241061130334487, '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': '3549586', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1078, 'n_words': 238}