From ede237110455455263a23637a4b4bff42039d161 Mon Sep 17 00:00:00 2001 From: Zambom Date: Thu, 22 Dec 2016 15:54:57 -0200 Subject: [PATCH] Adding pagination and creation button --- amadeus/templates/pagination.html | 11 +++++++++++ amadeus/templatetags/__init__.py | 0 amadeus/templatetags/pagination.py | 21 +++++++++++++++++++++ users/templates/users/list.html | 33 +++++++++++++++++++++------------ 4 files changed, 53 insertions(+), 12 deletions(-) create mode 100644 amadeus/templates/pagination.html create mode 100644 amadeus/templatetags/__init__.py create mode 100644 amadeus/templatetags/pagination.py diff --git a/amadeus/templates/pagination.html b/amadeus/templates/pagination.html new file mode 100644 index 0000000..982bb66 --- /dev/null +++ b/amadeus/templates/pagination.html @@ -0,0 +1,11 @@ +
+
+
    + {% for page_number in paginator.page_range %} + + {{ page_number }} + + {% endfor %} +
+
+
\ No newline at end of file diff --git a/amadeus/templatetags/__init__.py b/amadeus/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/amadeus/templatetags/__init__.py diff --git a/amadeus/templatetags/pagination.py b/amadeus/templatetags/pagination.py new file mode 100644 index 0000000..7b16a8e --- /dev/null +++ b/amadeus/templatetags/pagination.py @@ -0,0 +1,21 @@ +from django import template + +register = template.Library() + +@register.inclusion_tag('pagination.html') +def pagination(request, paginator, page_obj): + context = { + 'request': request, + 'paginator': paginator, + 'page_obj': page_obj, + } + + getvars = request.GET.copy() + + if 'page' in getvars: + del getvars['page'] + + if len(getvars) > 0: + context['getvars'] = '&%s' % getvars.urlencode() + + return context \ No newline at end of file diff --git a/users/templates/users/list.html b/users/templates/users/list.html index 8179496..2cc93d2 100644 --- a/users/templates/users/list.html +++ b/users/templates/users/list.html @@ -1,6 +1,6 @@ {% extends 'base.html' %} -{% load i18n django_bootstrap_breadcrumbs permission_tags static %} +{% load i18n pagination django_bootstrap_breadcrumbs permission_tags static %} {% block breadcrumbs %} {{ block.super }} @@ -21,18 +21,26 @@ {% endfor %} {% endif %} -
-
-
- -
-
- -
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+ - +
{% if users %} {% for acc in users %} @@ -57,6 +65,7 @@
{% endfor %} + {% pagination request paginator page_obj %} {% else %}
-- libgit2 0.21.2