From 6f52e88df4aa4a4ae7b005d3dd841cef34b4dbd6 Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Sat, 20 Jul 2013 20:18:11 -0300 Subject: [PATCH 1/2] Allow replacing << and >> with the first and last links --- .../bootstrap_toolkit/pagination.html | 28 +++++++++++++++---- .../templatetags/bootstrap_toolkit.py | 5 +++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html b/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html index 268318a..59fc9e2 100644 --- a/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html +++ b/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html @@ -3,9 +3,17 @@
diff --git a/bootstrap_toolkit/templatetags/bootstrap_toolkit.py b/bootstrap_toolkit/templatetags/bootstrap_toolkit.py index 07c1ea9..2e1571e 100644 --- a/bootstrap_toolkit/templatetags/bootstrap_toolkit.py +++ b/bootstrap_toolkit/templatetags/bootstrap_toolkit.py @@ -293,7 +293,8 @@ def bootstrap_pagination(page, **kwargs): return get_pagination_context(**pagination_kwargs) -def get_pagination_context(page, pages_to_show=11, url=None, size=None, align=None, extra=None): +def get_pagination_context(page, pages_to_show=11, always_show_first=False, always_show_last=False, + url=None, size=None, align=None, extra=None): """ Generate Bootstrap pagination context from a page object """ @@ -363,6 +364,8 @@ def get_pagination_context(page, pages_to_show=11, url=None, size=None, align=No # Build context object return { 'bootstrap_pagination_url': url, + 'always_show_first': always_show_first, + 'always_show_last': always_show_last, 'num_pages': num_pages, 'current_page': current_page, 'first_page': first_page, From 0f0ff43eeab8e19ee8d8021460f1a4abf8303bde Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Sat, 20 Jul 2013 20:47:41 -0300 Subject: [PATCH 2/2] Support adding previous and next buttons to the pager --- .../templates/bootstrap_toolkit/pagination.html | 10 ++++++++++ bootstrap_toolkit/templatetags/bootstrap_toolkit.py | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html b/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html index 59fc9e2..e2ae45d 100644 --- a/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html +++ b/bootstrap_toolkit/templates/bootstrap_toolkit/pagination.html @@ -3,6 +3,11 @@
    + {% if show_prev_and_next %} +
  • + +
  • + {% endif %} {% if always_show_first %} {% if 1 not in pages_shown %}
  • @@ -45,6 +50,11 @@
  • {% endif %} + {% if show_prev_and_next %} +
  • + +
  • + {% endif %}
diff --git a/bootstrap_toolkit/templatetags/bootstrap_toolkit.py b/bootstrap_toolkit/templatetags/bootstrap_toolkit.py index 2e1571e..d4a596a 100644 --- a/bootstrap_toolkit/templatetags/bootstrap_toolkit.py +++ b/bootstrap_toolkit/templatetags/bootstrap_toolkit.py @@ -294,7 +294,7 @@ def bootstrap_pagination(page, **kwargs): def get_pagination_context(page, pages_to_show=11, always_show_first=False, always_show_last=False, - url=None, size=None, align=None, extra=None): + show_prev_and_next=False, url=None, size=None, align=None, extra=None): """ Generate Bootstrap pagination context from a page object """ @@ -366,6 +366,7 @@ def get_pagination_context(page, pages_to_show=11, always_show_first=False, alwa 'bootstrap_pagination_url': url, 'always_show_first': always_show_first, 'always_show_last': always_show_last, + 'show_prev_and_next': show_prev_and_next, 'num_pages': num_pages, 'current_page': current_page, 'first_page': first_page,