comparison 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
comparison
equal deleted inserted replaced
160:2eb3984ccb15 161:445e1466a98d
80 page_num = int(request.GET.get('page', 1)) 80 page_num = int(request.GET.get('page', 1))
81 try: 81 try:
82 page = paginator.page(page_num) 82 page = paginator.page(page_num)
83 except InvalidPage: 83 except InvalidPage:
84 raise Http404 84 raise Http404
85
86 # Attach "goto page" navigation links onto those topics that have
87 # more than 1 page:
88
89 for topic in page.object_list:
90 if topic.post_count > POSTS_PER_PAGE:
91 pp = DiggPaginator(range(topic.post_count), POSTS_PER_PAGE,
92 body=2, tail=3, margin=1)
93 topic.page_range = pp.page(1).page_range
94 else:
95 topic.page_range = None
96
85 97
86 # we do this for the template since it is rendered twice 98 # we do this for the template since it is rendered twice
87 page_nav = render_to_string('forums/pagination.html', {'page': page}) 99 page_nav = render_to_string('forums/pagination.html', {'page': page})
88 100
89 can_moderate = _can_moderate(forum, request.user) 101 can_moderate = _can_moderate(forum, request.user)