##// END OF EJS Templates
Added ability to open fav posts as a feed with parameter
neko259 -
r1469:a16adec6 default
parent child Browse files
Show More
@@ -42,7 +42,7 b''
42 42 <a href="{% url 'feed' %}" title="{% trans 'Feed' %}">{% trans 'feed' %}</a>,
43 43 <a href="{% url 'random' %}" title="{% trans 'Random images' %}">{% trans 'random' %}</a>{% if has_fav_threads %},
44 44
45 <a href="#" id="fav-panel-btn">{% trans 'favorites' %} <span id="new-fav-post-count" {% if not new_post_count %}style="display: none" {% endif %}>{{ new_post_count }}</span></a>
45 <a href="{% url 'feed' %}?favorites" id="fav-panel-btn">{% trans 'favorites' %} <span id="new-fav-post-count" {% if not new_post_count %}style="display: none" {% endif %}>{{ new_post_count }}</span></a>
46 46 {% endif %}
47 47
48 48 {% if usernames %}
@@ -12,7 +12,6 b' POSTS_PER_PAGE = 10'
12 12 PARAMETER_CURRENT_PAGE = 'current_page'
13 13 PARAMETER_PAGINATOR = 'paginator'
14 14 PARAMETER_POSTS = 'posts'
15 PARAMETER_ADDITONAL_ATTRS = 'additional_attrs'
16 15
17 16 PARAMETER_PREV_LINK = 'prev_page_link'
18 17 PARAMETER_NEXT_LINK = 'next_page_link'
@@ -26,6 +25,7 b' class FeedView(PostMixin, BaseBoardView)'
26 25 def get(self, request):
27 26 page = request.GET.get('page', DEFAULT_PAGE)
28 27 tripcode = request.GET.get('tripcode', None)
28 favorites = 'favorites' in request.GET
29 29
30 30 params = self.get_context_data(request=request)
31 31
@@ -36,17 +36,16 b' class FeedView(PostMixin, BaseBoardView)'
36 36 '-pub_time').prefetch_related('images', 'thread', 'threads')
37 37 if tripcode:
38 38 posts = posts.filter(tripcode=tripcode)
39 if favorites:
40 fav_thread_ops = Post.objects.filter(id__in=settings_manager.get_fav_threads().keys())
41 fav_threads = [op.get_thread() for op in fav_thread_ops]
42 posts = posts.filter(threads__in=fav_threads)
39 43
40 44 paginator = get_paginator(posts, POSTS_PER_PAGE)
41 45 paginator.current_page = int(page)
42 46
43 47 params[PARAMETER_POSTS] = paginator.page(page).object_list
44 48
45 additional_params = dict()
46 if tripcode:
47 additional_params['tripcode'] = tripcode
48 params[PARAMETER_ADDITONAL_ATTRS] = '&tripcode=' + tripcode
49
50 49 paginator.set_url(reverse('feed'), request.GET.dict())
51 50
52 51 self.get_page_context(paginator, params, page)
General Comments 0
You need to be logged in to leave comments. Login now