<commit_before>from django.db import models
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.template.loader import render_to_string

import feedparser


class RSSContent(models.Model):
    link = models.URLField(_('link'))
    rendered_content = models.TextField(_('Pre-rendered content'), blank=True, editable=False)

    class Meta:
        abstract = True

    def render(self, **kwargs):
        return mark_safe(self.rendered_content)
        #u'<div class="rsscontent"> RSS: <a href="'+self.link+'">'+self.link+'</a></div')

    def cache_content(self):
        print u"Getting RSS feed at %s" % (self.link,)
        feed = feedparser.parse(self.link)

        print u"Pre-rendering content"
        self.rendered_content = render_to_string('rsscontent.html', {
            'feed': feed})

        self.save()
<commit_msg>Add last_updated field to RSSContent<commit_after>from datetime import datetime

from django.db import models
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.template.loader import render_to_string

import feedparser


class RSSContent(models.Model):
    link = models.URLField(_('link'))
    rendered_content = models.TextField(_('Pre-rendered content'), blank=True, editable=False)
    last_updated = models.DateTimeField(_('Last updated'), blank=True, null=True)

    class Meta:
        abstract = True

    def render(self, **kwargs):
        return mark_safe(self.rendered_content)
        #u'<div class="rsscontent"> RSS: <a href="'+self.link+'">'+self.link+'</a></div')

    def cache_content(self):
        print u"Getting RSS feed at %s" % (self.link,)
        feed = feedparser.parse(self.link)

        print u"Pre-rendering content"
        self.rendered_content = render_to_string('rsscontent.html', {
            'feed': feed})
        self.last_updated = datetime.now()

        self.save()

{'fraction_non_alphanumeric': 0.12150482968988308, 'fraction_numerical': 0.0, 'mean_word_length': 3.619718309859155, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '7460636', 'n_tokens_mistral': 600, 'n_tokens_neox': 572, 'n_words': 137}