You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
963 B
34 lines
963 B
# -*- coding: utf-8 -*-
|
|
from django.contrib.sites.models import Site
|
|
from django.contrib.syndication.views import Feed
|
|
from django.core.urlresolvers import reverse
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from .models import Post
|
|
|
|
|
|
class LatestEntriesFeed(Feed):
|
|
|
|
def link(self):
|
|
return reverse('blog:posts-latest')
|
|
|
|
def title(self):
|
|
return _('Blog articles on %(site_name)s') % {'site_name': Site.objects.get_current().name}
|
|
|
|
def items(self, obj=None):
|
|
return Post.objects.published().order_by('-date_published')[:10]
|
|
|
|
def item_title(self, item):
|
|
return item.safe_translation_getter('title')
|
|
|
|
def item_description(self, item):
|
|
return item.safe_translation_getter('abstract')
|
|
|
|
|
|
class TagFeed(LatestEntriesFeed):
|
|
|
|
def get_object(self, request, tag):
|
|
return tag # pragma: no cover
|
|
|
|
def items(self, obj=None):
|
|
return Post.objects.published().filter(tags__slug=obj)[:10]
|
|
|