##// END OF EJS Templates
New backend for fav threads. Now only last post ids are saved, no thread ids
New backend for fav threads. Now only last post ids are saved, no thread ids

File last commit:

r1946:473318e3 default
r2044:227641ed default
Show More
rss.py
79 lines | 2.0 KiB | text/x-python | PythonLexer
from django.contrib.syndication.views import Feed
from django.shortcuts import get_object_or_404
from boards import settings
from boards.models import Post, TagAlias
from boards.models.thread import STATUS_ARCHIVE
__author__ = 'nekorin'
MAX_ITEMS = settings.get_int('RSS', 'MaxItems')
# TODO Make tests for all of these
class AllThreadsFeed(Feed):
title = settings.get('Version', 'SiteName') + ' - All threads'
link = '/'
description_template = 'boards/rss/post.html'
def items(self):
return Post.objects.filter(opening=True).exclude(thread__status=STATUS_ARCHIVE).order_by('-id')[:MAX_ITEMS]
def item_title(self, item):
return item.title
def item_link(self, item):
return item.get_absolute_url()
def item_pubdate(self, item):
return item.pub_time
class TagThreadsFeed(Feed):
link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
return Post.objects.filter(opening=True, thread__tags__aliases__name__in=[obj]).exclude(thread__status=STATUS_ARCHIVE).order_by('-id')[:MAX_ITEMS]
def get_object(self, request, tag_name):
return get_object_or_404(TagAlias, name=tag_name).parent
def item_title(self, item):
return item.title
def item_link(self, item):
return item.get_absolute_url()
def item_pubdate(self, item):
return item.pub_time
def title(self, obj):
return obj.get_name()
class ThreadPostsFeed(Feed):
link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
return obj.get_thread().get_replies().order_by('-pub_time')[:MAX_ITEMS]
def get_object(self, request, post_id):
return get_object_or_404(Post, id=post_id)
def item_title(self, item):
return item.title
def item_link(self, item):
return item.get_absolute_url()
def item_pubdate(self, item):
return item.pub_time
def title(self, obj):
return obj.title