Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added pagination to community feed pages.

  • Loading branch information...
commit 6f4be88c8ff85828e8391811d76922c9190b8939 1 parent 5483763
Jacob Kaplan-Moss jacobian authored
1  TODO
View
@@ -1,3 +1,2 @@
-* Pagination for aggregator feed item details
* allow users to "own" feeds and self-edit
* allow users to "claim" legacy feeds (might do this by hand.)
7 django_website/aggregator/views.py
View
@@ -17,8 +17,11 @@ def index(request):
def feed_list(request, feed_type_slug):
feed_type = get_object_or_404(FeedType, slug=feed_type_slug)
- items = FeedItem.objects.filter(feed__feed_type=feed_type)
- return object_list(request, items)
+ return object_list(request,
+ queryset = FeedItem.objects.filter(feed__feed_type=feed_type),
+ paginate_by = 10,
+ extra_context = {'feed_type': feed_type},
+ )
@login_required
def add_feed(request, feed_type_slug):
21 django_website/templates/aggregator/feeditem_list.html
View
@@ -1,8 +1,12 @@
{% extends "base_community.html" %}
{% block content %}
-<h1>Community</h1>
-<h2 class="deck">This page, updated every hour, aggregates what's going on in the community.</h2>
+<h1>Django community: {{ feed_type.name }}
+ <a class="rss" href="{% url aggregator-feed feed_type.slug %}">RSS</a></h1>
+<h2 class="deck">
+ This page, updated regularly, aggregates {{ feed_type.name }}
+ from the Django community.
+</h2>
{% for item in object_list %}
<h2><a href="{{ item.link }}">{{ item.title }}</a></h2>
@@ -12,4 +16,17 @@ <h2 class="deck">This page, updated every hour, aggregates what's going on in th
</div>
<p class="small"><a href="{{ item.link }}">Read this post in context &raquo;</a></p>
{% endfor %}
+
+{% if is_paginated %}
+ <div class="pagination">
+ {% if page_obj.has_next %}
+ <a href="?page={{ page_obj.next_page_number }}">&larr; Older entries</a>
+ {% endif %}
+ {% if page_obj.has_previous and page_obj.has_next %}|{% endif %}
+ {% if page_obj.has_previous %}
+ <a href="?page={{ page_obj.previous_page_number }}">Newer entries &rarr;</a>
+ {% endif %}
+ </div>
+{% endif %}
+
{% endblock %}
1  media/css/base.css
View
@@ -84,6 +84,7 @@ body#community #content-main .module { width: 350px; float: left; display: inlin
body#community #content-main .first { margin-left: 20px; clear: left; }
body#community #content-main .last { margin-right: 5px; clear: right; }
body#community .hidden { display: none; }
+body#community div.pagination { text-align: center; margin-top: 1em; }
/* LISTS */
Please sign in to comment.
Something went wrong with that request. Please try again.