diff options
Diffstat (limited to 'askbot/utils/functions.py')
-rw-r--r-- | askbot/utils/functions.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/askbot/utils/functions.py b/askbot/utils/functions.py index 2579728b..592dcf43 100644 --- a/askbot/utils/functions.py +++ b/askbot/utils/functions.py @@ -132,27 +132,39 @@ def setup_paginator(context): if (context["pages"] <= LEADING_PAGE_RANGE_DISPLAYED): in_leading_range = in_trailing_range = True page_numbers = [n for n in range(1, context["pages"] + 1) if n > 0 and n <= context["pages"]] - elif (context["page"] <= LEADING_PAGE_RANGE): + elif (context["current_page_number"] <= LEADING_PAGE_RANGE): in_leading_range = True page_numbers = [n for n in range(1, LEADING_PAGE_RANGE_DISPLAYED + 1) if n > 0 and n <= context["pages"]] pages_outside_leading_range = [n + context["pages"] for n in range(0, -NUM_PAGES_OUTSIDE_RANGE, -1)] - elif (context["page"] > context["pages"] - TRAILING_PAGE_RANGE): + elif (context["current_page_number"] > context["pages"] - TRAILING_PAGE_RANGE): in_trailing_range = True page_numbers = [n for n in range(context["pages"] - TRAILING_PAGE_RANGE_DISPLAYED + 1, context["pages"] + 1) if n > 0 and n <= context["pages"]] pages_outside_trailing_range = [n + 1 for n in range(0, NUM_PAGES_OUTSIDE_RANGE)] else: - page_numbers = [n for n in range(context["page"] - ADJACENT_PAGES, context["page"] + ADJACENT_PAGES + 1) if n > 0 and n <= context["pages"]] + page_numbers = [n for n in range(context["current_page_number"] - ADJACENT_PAGES, context["current_page_number"] + ADJACENT_PAGES + 1) if n > 0 and n <= context["pages"]] pages_outside_leading_range = [n + context["pages"] for n in range(0, -NUM_PAGES_OUTSIDE_RANGE, -1)] pages_outside_trailing_range = [n + 1 for n in range(0, NUM_PAGES_OUTSIDE_RANGE)] + page_object = context['page_object'] + #patch for change in django 1.5 + if page_object.has_previous(): + previous_page_number = page_object.previous_page_number() + else: + previous_page_number = None + + if page_object.has_next(): + next_page_number = page_object.next_page_number() + else: + next_page_number = None + return { "base_url": context["base_url"], "is_paginated": context["is_paginated"], - "previous": context["previous"], - "has_previous": context["has_previous"], - "next": context["next"], - "has_next": context["has_next"], - "page": context["page"], + "previous": previous_page_number, + "has_previous": page_object.has_previous(), + "next": next_page_number, + "has_next": page_object.has_next(), + "page": context["current_page_number"], "pages": context["pages"], "page_numbers": page_numbers, "in_leading_range" : in_leading_range, |