<commit_before>from datetime import datetime
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _

from ella.core.models import Category
from ella.core.cache.utils import get_cached_object, get_cached_list
from ella.db.models import Publishable
from ella.core.box import Box


class Serie(models.Model, Publishable):

    title = models.CharField(_('Title'), max_length=96)
    slug = models.SlugField(_('Slug'), unique=True)
    perex = models.TextField(_('Perex'))
    description = models.TextField(_('Description'), blank=True)
    category = models.ForeignKey(Category, verbose_name=_('Category'))

    started = models.DateField(_('Started'))
    finished = models.DateField(_('Finished'), null=True, blank=True)

    @property
    def parts(self):
        return get_cached_list(SeriePart, serie=self)

    def is_active(self):
        today = datetime.date.today()
        return today > self.started and (self.finished is None or today < self.finished)
    is_active.short_description = _('Active')
    is_active.boolean = True

    def __unicode__(self):
        return u"%s" % self.title

    class Meta:
        verbose_name = _('Serie')
        verbose_name_plural = _('Series')


class SeriePart(models.Model):

    serie = models.ForeignKey(Serie, verbose_name=_('Serie'))
    target_ct = models.ForeignKey(ContentType)
    target_id = models.IntegerField()
    part_no = models.PositiveSmallIntegerField(_('Part no.'), default=1)

    @property
    def target(self):<commit_msg>Small changes in ella.series model.<commit_after>from datetime import datetime
from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.utils.translation import ugettext_lazy as _

from ella.core.models import Category
from ella.core.cache.utils import get_cached_object, get_cached_list
from ella.db.models import Publishable
from ella.core.box import Box


class Serie(models.Model, Publishable):

    title = models.CharField(_('Title'), max_length=96)
    slug = models.SlugField(_('Slug'), unique=True)
    perex = models.TextField(_('Perex'))
    description = models.TextField(_('Description'), blank=True)
    category = models.ForeignKey(Category, verbose_name=_('Category'))

    hide_newer_parts = models.BooleanField(_('Hide newer parts'), default=False)
    started = models.DateField(_('Started'))
    finished = models.DateField(_('Finished'), null=True, blank=True)

    @property
    def parts(self):
        return get_cached_list(SeriePart, serie=self)

    def is_active(self):
        today = datetime.date.today()
        return today > self.started and (self.finished is None or today < self.finished)
    is_active.short_description = _('Active')
    is_active.boolean = True

    def __unicode__(self):
        return u"%s" % self.title

    class Meta:
        verbose_name = _('Serie')
        verbose_name_plural = _('Series')


class SeriePart(models.Model):

    serie = models.ForeignKey(Serie, verbose_name=_('Serie'))
    target_ct = models.ForeignKey(ContentType)
    target_id = models.IntegerField()
    part_no = models.PositiveSmallIntegerField(_('Part no.'), default=1)

    @property
    def target(self):
{'fraction_non_alphanumeric': 0.11304613504430186, 'fraction_numerical': 0.0018331805682859762, 'mean_word_length': 4.213375796178344, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5964099', 'n_tokens_mistral': 982, 'n_tokens_neox': 957, 'n_words': 224}