Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 2495497

Browse files
author
staticdev
committed
Add pre-commit
1 parent 1d205ab commit 2495497

File tree

7 files changed

+107
-46
lines changed

7 files changed

+107
-46
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,4 @@ dmypy.json
129129
.pyre/
130130

131131
# Pytype
132-
.pytype/
132+
.pytype/

.pre-commit-config.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v3.0.1
4+
hooks:
5+
- id: check-toml
6+
- id: check-yaml
7+
- id: end-of-file-fixer
8+
- id: trailing-whitespace
9+
- id: check-added-large-files
10+
- repo: https://github.com/prettier/prettier
11+
rev: 2.0.5
12+
hooks:
13+
- id: prettier
14+
- repo: https://github.com/psf/black
15+
rev: 19.10b0
16+
hooks:
17+
- id: black
18+
- repo: https://gitlab.com/pycqa/flake8
19+
rev: 3.7.9
20+
hooks:
21+
- id: flake8
22+
additional_dependencies:
23+
- flake8-bandit==2.1.2
24+
- flake8-bugbear==20.1.4
25+
- flake8-docstrings==1.5.0
26+
- pep8-naming==0.10.0
27+
- darglint==1.2.3
28+
- repo: https://github.com/asottile/reorder_python_imports
29+
rev: v2.3.0
30+
hooks:
31+
- id: reorder-python-imports
32+
args: [--application-directories=src]

.travis.yml

+9-9
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ env:
1717
- DJANGO="Django>=2.1.0,<2.2.0"
1818

1919
install:
20-
- pip install -q $DJANGO
21-
- pip install coveralls
20+
- pip install -q $DJANGO
21+
- pip install coveralls
2222

2323
script:
2424
- coverage run runtests.py
25-
25+
2626
after_success:
2727
- coveralls
2828

@@ -32,28 +32,28 @@ matrix:
3232
env: DJANGO="Django>=1.7.0,<1.8.0"
3333
- python: "3.6"
3434
env: DJANGO="Django>=1.7.0,<1.8.0"
35-
35+
3636
- python: "3.6"
3737
env: DJANGO="Django>=1.8.0,<1.9.0"
38-
38+
3939
- python: "3.3"
4040
env: DJANGO="Django>=1.9.0,<1.10.0"
4141
- python: "3.6"
4242
env: DJANGO="Django>=1.9.0,<1.10.0"
43-
43+
4444
- python: "3.3"
4545
env: DJANGO="Django>=1.10.0,<1.11.0"
4646
- python: "3.6"
4747
env: DJANGO="Django>=1.10.0,<1.11.0"
48-
48+
4949
- python: "3.3"
5050
env: DJANGO="Django>=1.11.0,<2.0.0"
51-
51+
5252
- python: "2.7"
5353
env: DJANGO="Django>=2.0.0,<2.1.0"
5454
- python: "3.3"
5555
env: DJANGO="Django>=2.0.0,<2.1.0"
56-
56+
5757
- python: "2.7"
5858
env: DJANGO="Django>=2.1.0,<2.2.0"
5959
- python: "3.3"

src/django_pagination_bootstrap/paginator.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from django.core.paginator import Paginator, Page, PageNotAnInteger, EmptyPage
1+
from django.core.paginator import EmptyPage
2+
from django.core.paginator import Page
3+
from django.core.paginator import PageNotAnInteger
4+
from django.core.paginator import Paginator
25

36

47
class InfinitePaginator(Paginator):
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
1-
{% if is_paginated %}
2-
{% load i18n %}
1+
{% if is_paginated %} {% load i18n %}
32

43
<nav aria-label="Page pagination">
54
<ul class="pagination">
6-
{% if page_obj.has_previous %}
7-
<li class="page-item"><a class="page-link" href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}">&laquo;</a></li>
8-
{% else %}
9-
<li class="page-item disabled"><a class="page-link" href="#" onclick="javascript: return false;">&laquo;</a></li>
10-
{% endif %}
11-
{% for page in pages %}
12-
{% if page %}
13-
{% ifequal page page_obj.number %}
14-
<li class="page-item active"><a class="page-link" href="#" onclick="javascript: return false;">{{ page }}</a></li>
15-
{% else %}
16-
<li class="page-item"><a class="page-link" href="?page={{ page }}{{ getvars }}{{ hashtag }}">{{ page }}</a></li>
17-
{% endifequal %}
5+
{% if page_obj.has_previous %}
6+
<li class="page-item">
7+
<a
8+
class="page-link"
9+
href="?page={{ page_obj.previous_page_number }}{{ getvars }}{{ hashtag }}"
10+
>&laquo;</a
11+
>
12+
</li>
13+
{% else %}
14+
<li class="page-item disabled">
15+
<a class="page-link" href="#" onclick="javascript: return false;"
16+
>&laquo;</a
17+
>
18+
</li>
19+
{% endif %} {% for page in pages %} {% if page %} {% ifequal page
20+
page_obj.number %}
21+
<li class="page-item active">
22+
<a class="page-link" href="#" onclick="javascript: return false;"
23+
>{{ page }}</a
24+
>
25+
</li>
1826
{% else %}
19-
<li class="page-item disabled"><a class="page-link" href="#" onclick="javascript: return false;">...</a></li>
27+
<li class="page-item">
28+
<a class="page-link" href="?page={{ page }}{{ getvars }}{{ hashtag }}"
29+
>{{ page }}</a
30+
>
31+
</li>
32+
{% endifequal %} {% else %}
33+
<li class="page-item disabled">
34+
<a class="page-link" href="#" onclick="javascript: return false;">...</a>
35+
</li>
36+
{% endif %} {% endfor %} {% if page_obj.has_next %}
37+
<li class="page-item">
38+
<a
39+
class="page-link"
40+
href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}"
41+
>&raquo;</a
42+
>
43+
</li>
44+
{% else %}
45+
<li class="page-item disabled">
46+
<a class="page-link" href="#" onclick="javascript: return false;"
47+
>&raquo;</a
48+
>
49+
</li>
2050
{% endif %}
21-
{% endfor %}
22-
{% if page_obj.has_next %}
23-
<li class="page-item"><a class="page-link" href="?page={{ page_obj.next_page_number }}{{ getvars }}{{ hashtag }}">&raquo;</a></li>
24-
{% else %}
25-
<li class="page-item disabled"><a class="page-link" href="#" onclick="javascript: return false;">&raquo;</a></li>
26-
{% endif %}
2751
</ul>
2852
{% endif %}
2953
</nav>
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-

src/django_pagination_bootstrap/templatetags/pagination_tags.py

+16-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
# -*- coding: utf-8 -*-
22
from django import template
3-
from django.http import Http404
4-
from django.core.paginator import Paginator, InvalidPage, EmptyPage, PageNotAnInteger
53
from django.conf import settings
4+
from django.core.paginator import EmptyPage
5+
from django.core.paginator import InvalidPage
6+
from django.core.paginator import PageNotAnInteger
7+
from django.core.paginator import Paginator
8+
from django.http import Http404
69

710
register = template.Library()
811

@@ -59,16 +62,16 @@ def do_autopaginate(parser, token):
5962
class AutoPaginateNode(template.Node):
6063
"""
6164
Emits the required objects to allow for Digg-style pagination.
62-
65+
6366
First, it looks in the current context for the variable specified, and using
64-
that object, it emits a simple ``Paginator`` and the current page object
67+
that object, it emits a simple ``Paginator`` and the current page object
6568
into the context names ``paginator`` and ``page_obj``, respectively.
66-
69+
6770
It will then replace the variable specified with only the objects for the
6871
current page.
69-
72+
7073
.. note::
71-
74+
7275
It is recommended to use *{% paginate %}* after using the autopaginate
7376
tag. If you choose not to use *{% paginate %}*, make sure to display the
7477
list of available pages, or else the application may seem to be buggy.
@@ -147,20 +150,20 @@ def paginate(context, window=DEFAULT_WINDOW, hashtag=""):
147150
Digg-like display of the available pages, given the current page. If there
148151
are too many pages to be displayed before and after the current page, then
149152
elipses will be used to indicate the undisplayed gap between page numbers.
150-
153+
151154
Requires one argument, ``context``, which should be a dictionary-like data
152155
structure and must contain the following keys:
153-
156+
154157
``paginator``
155158
A ``Paginator`` or ``QuerySetPaginator`` object.
156-
159+
157160
``page_obj``
158-
This should be the result of calling the page method on the
161+
This should be the result of calling the page method on the
159162
aforementioned ``Paginator`` or ``QuerySetPaginator`` object, given
160163
the current page.
161-
164+
162165
This same ``context`` dictionary-like data structure may also include:
163-
166+
164167
``getvars``
165168
A dictionary of all of the **GET** parameters in the current request.
166169
This is useful to maintain certain types of state, even when requesting

0 commit comments

Comments
 (0)