<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.categories.models import Category
from dash.orgs.models import Org
from smartmin.models import SmartModel

from django.db import models
from django.utils.translation import ugettext_lazy as _


class NewsItem(SmartModel):
    title = models.CharField(max_length=255, help_text=_("The title for this item"))

    description = models.TextField(blank=True, null=True, help_text=_("A short summary description for this item"))

    link = models.CharField(max_length=255, help_text=_("A link that should be associated with this item"))

    category = models.ForeignKey(
        Category, on_delete=models.PROTECT, related_name="news", help_text=_("The category this item belongs to")
    )

    org = models.ForeignKey(Org, on_delete=models.PROTECT, help_text=_("The organization this item belongs to"))

    def short_description(self):
        if len(self.description) > 300:
            return self.description[:300] + "..."
        return self.description

    def as_brick_json(self):
        return dict(
            title=self.title,
            description=self.short_description(),
            link=self.link,
            created_on=self.created_on.strftime("%b %d, %Y"),
        )


class Video(SmartModel):<commit_msg>Refactor created date for News by using the localization to format it<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals

from dash.categories.models import Category
from dash.orgs.models import Org
from smartmin.models import SmartModel

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils import formats

class NewsItem(SmartModel):
    title = models.CharField(max_length=255, help_text=_("The title for this item"))

    description = models.TextField(blank=True, null=True, help_text=_("A short summary description for this item"))

    link = models.CharField(max_length=255, help_text=_("A link that should be associated with this item"))

    category = models.ForeignKey(
        Category, on_delete=models.PROTECT, related_name="news", help_text=_("The category this item belongs to")
    )

    org = models.ForeignKey(Org, on_delete=models.PROTECT, help_text=_("The organization this item belongs to"))

    def short_description(self):
        if len(self.description) > 300:
            return self.description[:300] + "..."
        return self.description

    def as_brick_json(self):
        return dict(
            title=self.title,
            description=self.short_description(),
            link=self.link,
            created_on=formats.date_format(self.created_on, format="b d, Y", use_l10n=True),
        )


class Video(SmartModel):
{'fraction_non_alphanumeric': 0.10003522367030644, 'fraction_numerical': 0.009862627685804861, 'mean_word_length': 3.7651006711409396, 'pattern_counts': {'":': 0, '<': 3, '<?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': '7184390', 'n_tokens_mistral': 828, 'n_tokens_neox': 789, 'n_words': 220}