# HG changeset patch # User Brian Neal # Date 1261452703 0 # Node ID 445e1466a98dd6d23be0e23d74ad1e177b4eeb41 # Parent 2eb3984ccb15e8ec481444788d1c3490e433d6d7 Implement #47; add goto page links on topics in the forum index view. diff -r 2eb3984ccb15 -r 445e1466a98d gpp/forums/views.py --- 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}) diff -r 2eb3984ccb15 -r 445e1466a98d gpp/templates/forums/forum_index.html --- 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 %}Sticky{% endif %} {% if topic.locked %}Locked{% endif %} -

{{ topic.name }}

+

{{ topic.name }}

+ {% if topic.page_range %} + Goto page: [ + {% for n in topic.page_range %} + {% if n %} + {{ n }} + {% else %} + … + {% endif %} + {% endfor %} + ] + {% endif %} + {{ topic.reply_count }} {{ topic.user.username }} {{ topic.view_count }} diff -r 2eb3984ccb15 -r 445e1466a98d media/css/base.css --- a/media/css/base.css Tue Dec 22 02:08:05 2009 +0000 +++ b/media/css/base.css Tue Dec 22 03:31:43 2009 +0000 @@ -198,6 +198,9 @@ width:10%; text-align:center; } +table.forum-index-table h4 { + margin-bottom: 4px; +} table.forum-topic { border-top:1px solid black; border-left:1px solid black;