##// END OF EJS Templates
Another word for 'all threads'
Another word for 'all threads'

File last commit:

r1705:d6dc7890 default
r1734:0f5e5df4 default
Show More
feed.py
74 lines | 2.5 KiB | text/x-python | PythonLexer
neko259
Added all posts feed
r1165 from django.core.urlresolvers import reverse
neko259
Get all posts with the same tripcode
r1302 from django.shortcuts import render
neko259
Added all posts feed
r1165
neko259
Added setting for posts per page in feeds
r1681 from boards import settings
neko259
Added all posts feed
r1165 from boards.abstracts.paginator import get_paginator
neko259
Don't show posts from ignored tag threads in the feed
r1170 from boards.abstracts.settingsmanager import get_settings_manager
neko259
Get all posts with the same tripcode
r1302 from boards.models import Post
neko259
Added all posts feed
r1165 from boards.views.base import BaseBoardView
from boards.views.posting_mixin import PostMixin
neko259
Added setting for posts per page in feeds
r1681 POSTS_PER_PAGE = settings.get_int('View', 'PostsPerPage')
neko259
Added all posts feed
r1165
PARAMETER_CURRENT_PAGE = 'current_page'
PARAMETER_PAGINATOR = 'paginator'
PARAMETER_POSTS = 'posts'
PARAMETER_PREV_LINK = 'prev_page_link'
PARAMETER_NEXT_LINK = 'next_page_link'
TEMPLATE = 'boards/feed.html'
DEFAULT_PAGE = 1
class FeedView(PostMixin, BaseBoardView):
neko259
Use GET parameter to specify a page instead of different url reversers
r1204 def get(self, request):
page = request.GET.get('page', DEFAULT_PAGE)
neko259
Get all posts with the same tripcode
r1302 tripcode = request.GET.get('tripcode', None)
neko259
Added ability to open fav posts as a feed with parameter
r1469 favorites = 'favorites' in request.GET
neko259
Feed of posts for the specific IP (works only for moderators who can delete posts)
r1641 ip = request.GET.get('ip', None)
neko259
Use GET parameter to specify a page instead of different url reversers
r1204
neko259
Added all posts feed
r1165 params = self.get_context_data(request=request)
neko259
Don't show posts from ignored tag threads in the feed
r1170 settings_manager = get_settings_manager(request)
neko259
Get all posts with the same tripcode
r1302 posts = Post.objects.exclude(
neko259
Removed multitread posts 'feature'
r1704 thread__tags__in=settings_manager.get_hidden_tags()).order_by(
'-pub_time').prefetch_related('attachments', 'thread')
neko259
Get all posts with the same tripcode
r1302 if tripcode:
posts = posts.filter(tripcode=tripcode)
neko259
Added ability to open fav posts as a feed with parameter
r1469 if favorites:
fav_thread_ops = Post.objects.filter(id__in=settings_manager.get_fav_threads().keys())
fav_threads = [op.get_thread() for op in fav_thread_ops]
neko259
Fixed post count updating
r1705 posts = posts.filter(thread__in=fav_threads)
neko259
Feed of posts for the specific IP (works only for moderators who can delete posts)
r1641 if ip and request.user.has_perm('post_delete'):
posts = posts.filter(poster_ip=ip)
neko259
Get all posts with the same tripcode
r1302
paginator = get_paginator(posts, POSTS_PER_PAGE)
neko259
Added all posts feed
r1165 paginator.current_page = int(page)
params[PARAMETER_POSTS] = paginator.page(page).object_list
neko259
Made feed view use the new-style paginator links
r1378 paginator.set_url(reverse('feed'), request.GET.dict())
self.get_page_context(paginator, params, page)
neko259
Added all posts feed
r1165
return render(request, TEMPLATE, params)
# TODO Dedup this into PagedMixin
neko259
Made feed view use the new-style paginator links
r1378 def get_page_context(self, paginator, params, page):
neko259
Added all posts feed
r1165 """
Get pagination context variables
"""
params[PARAMETER_PAGINATOR] = paginator
current_page = paginator.page(int(page))
params[PARAMETER_CURRENT_PAGE] = current_page
if current_page.has_previous():
neko259
Made feed view use the new-style paginator links
r1378 params[PARAMETER_PREV_LINK] = paginator.get_page_url(
current_page.previous_page_number())
neko259
Added all posts feed
r1165 if current_page.has_next():
neko259
Made feed view use the new-style paginator links
r1378 params[PARAMETER_NEXT_LINK] = paginator.get_page_url(
current_page.next_page_number())
neko259
Added all posts feed
r1165