Mercurial > public > sg101
diff gpp/forums/views.py @ 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 | 152d77265da6 |
children | cf9f9d4c4d54 |
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})