<commit_before>from datetime import datetime
from django.db import models
from django.shortcuts import get_object_or_404
from django.utils.encoding import smart_unicode
from django.utils.translation import gettext_lazy as _
from cms.models import CMSPlugin
from taggit.models import Tag
from taggit.managers import TaggableManager
from utils import template_choices


def get_choices(self, include_blank=False):
    """Returns choices with a default blank choices included, for use
    as SelectField choices for this field."""
    rel_model = self.rel.to
    return [(getattr(x, self.rel.get_related_field().attname), smart_unicode(x))
                for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]

# hack to get list_filter working with TaggableManager field
setattr(TaggableManager, get_choices.__name__, get_choices)


class QuoteManager(models.Manager):
    def by_id(self, id):
        """Retrieve by ID"""
        return get_object_or_404(self, pk=id)

    def active(self, **kw):
        return self.filter(active=True, **kw).distinct()

    def by_tag(self, tag, **kw):
        if tag is None:
            return self.active(**kw)
        return self.active(tags__name=tag, **kw)


class Quote(models.Model):
    """The quote model."""

    author = models.CharField(_('Author'), max_length=100, blank=False,
        help_text=_("The name of the quote author"))
    text = models.TextField(_('Quote'), blank=False, null=False,
        help_text=_("The quote given."))
    active = models.BooleanField(_("Enabled"), default=True)
    #created = models.DateField(_("Date created"), null=True, blank=True)

    tags = TaggableManager()
    objects = QuoteManager()

    def get_tags(self):
        return u', '.join([tag.name for tag in self.tags.all()])
    get_tags.short_description = 'Tags'
<commit_msg>tags not required<commit_after>from datetime import datetime
from django.db import models
from django.shortcuts import get_object_or_404
from django.utils.encoding import smart_unicode
from django.utils.translation import gettext_lazy as _
from cms.models import CMSPlugin
from taggit.models import Tag
from taggit.managers import TaggableManager
from utils import template_choices


def get_choices(self, include_blank=False):
    """Returns choices with a default blank choices included, for use
    as SelectField choices for this field."""
    rel_model = self.rel.to
    return [(getattr(x, self.rel.get_related_field().attname), smart_unicode(x))
                for x in rel_model._default_manager.complex_filter(self.rel.limit_choices_to)]

# hack to get list_filter working with TaggableManager field
setattr(TaggableManager, get_choices.__name__, get_choices)


class QuoteManager(models.Manager):
    def by_id(self, id):
        """Retrieve by ID"""
        return get_object_or_404(self, pk=id)

    def active(self, **kw):
        return self.filter(active=True, **kw).distinct()

    def by_tag(self, tag, **kw):
        if tag is None:
            return self.active(**kw)
        return self.active(tags__name=tag, **kw)


class Quote(models.Model):
    """The quote model."""

    author = models.CharField(_('Author'), max_length=100, blank=False,
        help_text=_("The name of the quote author"))
    text = models.TextField(_('Quote'), blank=False, null=False,
        help_text=_("The quote given."))
    active = models.BooleanField(_("Enabled"), default=True)
    #created = models.DateField(_("Date created"), null=True, blank=True)

    tags = TaggableManager(blank=True)
    objects = QuoteManager()

    def get_tags(self):
        return u', '.join([tag.name for tag in self.tags.all()])
    get_tags.short_description = 'Tags'

{'fraction_non_alphanumeric': 0.11144090663788452, 'fraction_numerical': 0.004856988667026443, 'mean_word_length': 4.029850746268656, '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': '7557763', 'n_tokens_mistral': 1137, 'n_tokens_neox': 1100, 'n_words': 306}