##// END OF EJS Templates
Fixed thread OP id in thread view. Fixed reply count in thread view
Fixed thread OP id in thread view. Fixed reply count in thread view

File last commit:

r402:f1273cae default
r404:80f183eb 1.4 default
Show More
rss.py
79 lines | 2.1 KiB | text/x-python | PythonLexer
from django.contrib.syndication.views import Feed
from django.core.urlresolvers import reverse
from django.shortcuts import get_object_or_404
from boards.models import Post, Tag
from neboard import settings
__author__ = 'neko259'
# TODO Make tests for all of these
class AllThreadsFeed(Feed):
title = settings.SITE_NAME + ' - All threads'
link = '/'
description_template = 'boards/rss/post.html'
def items(self):
return Post.objects.get_threads() # TODO Order this by OP's pub time
def item_title(self, item):
return item.get_opening_post().title
def item_link(self, item):
return reverse('thread', args={item.get_opening_post().id})
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.get_threads(tag=obj) # TODO Order this by OP's pub time
def get_object(self, request, tag_name):
return get_object_or_404(Tag, name=tag_name)
def item_title(self, item):
return item.get_opening_post().title
def item_link(self, item):
return reverse('thread', args={item.get_opening_post().id})
def item_pubdate(self, item):
return item.get_pub_time()
def title(self, obj):
return obj.name
class ThreadPostsFeed(Feed):
link = '/'
description_template = 'boards/rss/post.html'
def items(self, obj):
return get_object_or_404(Post, id=obj).thread_new.get_replies()
def get_object(self, request, post_id):
return post_id
def item_title(self, item):
return item.title
def item_link(self, item):
if not item.is_opening():
return reverse('thread', args={item.thread_new.get_opening_post()
.id}) + "#" + str(item.id)
else:
return reverse('thread', args={item.id})
def item_pubdate(self, item):
return item.pub_time
def title(self, obj):
return get_object_or_404(Post, id=obj).title