Commit ede237110455455263a23637a4b4bff42039d161
1 parent
108cddfa
Exists in
master
and in
3 other branches
Adding pagination and creation button
Showing
4 changed files
with
53 additions
and
12 deletions
Show diff stats
@@ -0,0 +1,11 @@ | @@ -0,0 +1,11 @@ | ||
1 | +<div class="row-fluid"> | ||
2 | + <div class="col-md-12 col-lg-12 col-sm-12 col-xs-12 text-center"> | ||
3 | + <ul class="pagination"> | ||
4 | + {% for page_number in paginator.page_range %} | ||
5 | + <li{% if page_obj.number == page_number %} class="active"{% endif %}> | ||
6 | + <a href="?page={{ page_number }}{{ getvars }}">{{ page_number }}</a> | ||
7 | + </li> | ||
8 | + {% endfor %} | ||
9 | + </ul> | ||
10 | + </div> | ||
11 | +</div> | ||
0 | \ No newline at end of file | 12 | \ No newline at end of file |
@@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
1 | +from django import template | ||
2 | + | ||
3 | +register = template.Library() | ||
4 | + | ||
5 | +@register.inclusion_tag('pagination.html') | ||
6 | +def pagination(request, paginator, page_obj): | ||
7 | + context = { | ||
8 | + 'request': request, | ||
9 | + 'paginator': paginator, | ||
10 | + 'page_obj': page_obj, | ||
11 | + } | ||
12 | + | ||
13 | + getvars = request.GET.copy() | ||
14 | + | ||
15 | + if 'page' in getvars: | ||
16 | + del getvars['page'] | ||
17 | + | ||
18 | + if len(getvars) > 0: | ||
19 | + context['getvars'] = '&%s' % getvars.urlencode() | ||
20 | + | ||
21 | + return context | ||
0 | \ No newline at end of file | 22 | \ No newline at end of file |
users/templates/users/list.html
1 | {% extends 'base.html' %} | 1 | {% extends 'base.html' %} |
2 | 2 | ||
3 | -{% load i18n django_bootstrap_breadcrumbs permission_tags static %} | 3 | +{% load i18n pagination django_bootstrap_breadcrumbs permission_tags static %} |
4 | 4 | ||
5 | {% block breadcrumbs %} | 5 | {% block breadcrumbs %} |
6 | {{ block.super }} | 6 | {{ block.super }} |
@@ -21,18 +21,26 @@ | @@ -21,18 +21,26 @@ | ||
21 | </div> | 21 | </div> |
22 | {% endfor %} | 22 | {% endfor %} |
23 | {% endif %} | 23 | {% endif %} |
24 | - <form action="" method="GET" class="form-horizontal"> | ||
25 | - <div class="form-group"> | ||
26 | - <div class="col-md-11 col-sm-11 col-xs-11"> | ||
27 | - <input type="text" class="form-control" name="search" placeholder="{% trans 'Search...' %}" /> | ||
28 | - </div> | ||
29 | - <div class="col-md-1 col-sm-1 col-xs-1"> | ||
30 | - <button type="submit" class="btn btn-fab btn-fab-mini"> | ||
31 | - <i class="material-icons">search</i> | ||
32 | - </button> | ||
33 | - </div> | 24 | + |
25 | + <div class="row"> | ||
26 | + <div class="col-md-9"> | ||
27 | + <form action="" method="GET" class="form-horizontal"> | ||
28 | + <div class="form-group"> | ||
29 | + <div class="col-md-11 col-sm-11 col-xs-11"> | ||
30 | + <input type="text" class="form-control" name="search" placeholder="{% trans 'Search...' %}" /> | ||
31 | + </div> | ||
32 | + <div class="col-md-1 col-sm-1 col-xs-1"> | ||
33 | + <button type="submit" class="btn btn-fab btn-fab-mini"> | ||
34 | + <i class="fa fa-search"></i> | ||
35 | + </button> | ||
36 | + </div> | ||
37 | + </div> | ||
38 | + </form> | ||
39 | + </div> | ||
40 | + <div class="col-md-3"> | ||
41 | + <a href="#" class="pull-right btn btn-primary btn-raised btn-md"><i class="fa fa-plus"></i> {% trans 'Create User' %}</a> | ||
34 | </div> | 42 | </div> |
35 | - </form> | 43 | + </div> |
36 | 44 | ||
37 | {% if users %} | 45 | {% if users %} |
38 | {% for acc in users %} | 46 | {% for acc in users %} |
@@ -57,6 +65,7 @@ | @@ -57,6 +65,7 @@ | ||
57 | </div> | 65 | </div> |
58 | </div> | 66 | </div> |
59 | {% endfor %} | 67 | {% endfor %} |
68 | + {% pagination request paginator page_obj %} | ||
60 | {% else %} | 69 | {% else %} |
61 | <div class="row"> | 70 | <div class="row"> |
62 | <div class="col-md-12 col-sm-12 col-xs-12"> | 71 | <div class="col-md-12 col-sm-12 col-xs-12"> |