<commit_before><commit_msg>New file for storing RSS/Atom feeds.<commit_after>"""
    This file stores several RSS/Atom feeds :
        - LatestProposalsFeed

    Django doc: https://docs.djangoproject.com/en/dev/ref/contrib/syndication/
    Related issue: https://projets.lqdn.fr/issues/304
"""
from django.conf import settings
from django.core.urlresolvers import reverse
from django.contrib.syndication.views import Feed

from votes.models import Proposal


ITEMS_PER_FEED = 10


class LatestProposalsFeed(Feed):
    title = "Latest Proposals"
    link = settings.ROOT_URL
    description = "This feed provides the latest tracked proposals of %s." % link

    def items(self):
        """
        Return the last ITEMS_PER_FEED proposals.
        """
        # Thanks to http://stackoverflow.com/questions/981375
        sorted_proposals = sorted(Proposal.objects.all(), key=lambda a: a.date)
        return sorted_proposals[-ITEMS_PER_FEED:]

    def item_title(self, item):
        return item.title

    def item_description(self, item):
        return ""

    def item_link(self, item):
        return reverse('votes:detail', args=[item.id])

{'fraction_non_alphanumeric': 0.10104529616724739, 'fraction_numerical': 0.009581881533101045, 'mean_word_length': 3.224264705882353, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '4358643', 'n_tokens_mistral': 372, 'n_tokens_neox': 346, 'n_words': 87}