Mercurial > public > sg101
changeset 161:445e1466a98d
Implement #47; add goto page links on topics in the forum index view.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 22 Dec 2009 03:31:43 +0000 |
parents | 2eb3984ccb15 |
children | 6a5bdcf93ad3 |
files | gpp/forums/views.py gpp/templates/forums/forum_index.html media/css/base.css |
diffstat | 3 files changed, 28 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/forums/views.py Tue Dec 22 02:08:05 2009 +0000 +++ b/gpp/forums/views.py Tue Dec 22 03:31:43 2009 +0000 @@ -83,6 +83,18 @@ except InvalidPage: raise Http404 + # Attach "goto page" navigation links onto those topics that have + # more than 1 page: + + for topic in page.object_list: + if topic.post_count > POSTS_PER_PAGE: + pp = DiggPaginator(range(topic.post_count), POSTS_PER_PAGE, + body=2, tail=3, margin=1) + topic.page_range = pp.page(1).page_range + else: + topic.page_range = None + + # we do this for the template since it is rendered twice page_nav = render_to_string('forums/pagination.html', {'page': page})
--- a/gpp/templates/forums/forum_index.html Tue Dec 22 02:08:05 2009 +0000 +++ b/gpp/templates/forums/forum_index.html Tue Dec 22 03:31:43 2009 +0000 @@ -35,7 +35,19 @@ {% if topic.sticky %}<img src="{{ MEDIA_URL }}icons/asterisk_orange.png" alt="Sticky" title="Sticky" class="forums-topic-icon" />{% endif %} {% if topic.locked %}<img src="{{ MEDIA_URL }}icons/lock.png" alt="Locked" title="Locked" class="forums-topic-icon" />{% endif %} - <h4><a href="{{ topic.get_absolute_url }}">{{ topic.name }}</a></h4></td> + <h4><a href="{{ topic.get_absolute_url }}">{{ topic.name }}</a></h4> + {% if topic.page_range %} + <span class="small">Goto page: [ + {% for n in topic.page_range %} + {% if n %} + <a href="{{ topic.get_absolute_url }}?page={{ n }}">{{ n }}</a> + {% else %} + … + {% endif %} + {% endfor %} + ]</span> + {% endif %} + </td> <td class="forum-index_replies">{{ topic.reply_count }}</td> <td class="forum-index_author"><a href="{% url bio-view_profile username=topic.user.username %}" title="View profile for {{ topic.user.username }}">{{ topic.user.username }}</a></td> <td class="forum-index_views">{{ topic.view_count }}</td>