Skip to content

Commit

Permalink
Merge pull request zyga#34 from atugushev/master
Browse files Browse the repository at this point in the history
Convert doctests to django unittests and add travis-ci support
  • Loading branch information
zyga committed Jan 6, 2016
2 parents cc09a6e + 4e8ac7d commit 5432e8f
Show file tree
Hide file tree
Showing 9 changed files with 525 additions and 283 deletions.
67 changes: 67 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
language: python
python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "3.5"
env:
matrix:
- DJANGO_VERSION=1.2
- DJANGO_VERSION=1.3
- DJANGO_VERSION=1.4
- DJANGO_VERSION=1.5
- DJANGO_VERSION=1.6
- DJANGO_VERSION=1.7
- DJANGO_VERSION=1.8
- DJANGO_VERSION=1.9
install:
- pip install 'coverage<4' # coverage>=4 has issues with python3
- pip install -q Django==$DJANGO_VERSION coveralls
- python setup.py egg_info
script: coverage run --source='linaro_django_pagination' --omit *runner*,*test_project* setup.py test
after_success:
- coveralls
matrix:
include:
- python: "2.6"
env: DJANGO_VERSION=1.4
- python: "2.6"
env: DJANGO_VERSION=1.5
- python: "2.6"
env: DJANGO_VERSION=1.6
exclude:
- python: "3.2"
env: DJANGO_VERSION=1.2 # Unsupported
- python: "3.2"
env: DJANGO_VERSION=1.3 # Unsupported
- python: "3.2"
env: DJANGO_VERSION=1.4 # Unsupported
- python: "3.2"
env: DJANGO_VERSION=1.9 # Unsupported
- python: "3.3"
env: DJANGO_VERSION=1.9 # ImportError: cannot import name find_spec
- python: "3.3"
env: DJANGO_VERSION=1.2 # Unsupported
- python: "3.3"
env: DJANGO_VERSION=1.3 # Unsupported
- python: "3.3"
env: DJANGO_VERSION=1.4 # Unsupported
- python: "3.4"
env: DJANGO_VERSION=1.2 # Unsupported
- python: "3.4"
env: DJANGO_VERSION=1.3 # Unsupported
- python: "3.4"
env: DJANGO_VERSION=1.4 # Unsupported
- python: "3.5"
env: DJANGO_VERSION=1.2 # Unsupported
- python: "3.5"
env: DJANGO_VERSION=1.3 # Unsupported
- python: "3.5"
env: DJANGO_VERSION=1.4 # Unsupported
- python: "3.5"
env: DJANGO_VERSION=1.5 # Unsupported
- python: "3.5"
env: DJANGO_VERSION=1.7 # AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
- python: "3.5"
env: DJANGO_VERSION=1.6 # AttributeError: module 'html.parser' has no attribute 'HTMLParseError'
11 changes: 11 additions & 0 deletions README → README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
========================
Linaro Django Pagination
========================

.. image:: https://travis-ci.org/zyga/django-pagination.svg?branch=master
:target: https://travis-ci.org/zyga/django-pagination

.. image:: https://coveralls.io/repos/zyga/django-pagination/badge.svg?branch=master&service=github
:target: https://coveralls.io/github/zyga/django-pagination?branch=master


About the fork
--------------

Expand Down
14 changes: 9 additions & 5 deletions linaro_django_pagination/templatetags/pagination_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ def __init__(self, queryset_var, multiple_paginations, paginate_by=None,
self.multiple_paginations = multiple_paginations

def render(self, context):
if self.multiple_paginations or getattr(context, "paginator", None):
# Save multiple_paginations state in context
if self.multiple_paginations and 'multiple_paginations' not in context:
context['multiple_paginations'] = True

if context.get('multiple_paginations') or getattr(context, "paginator", None):
page_suffix = '_%s' % self.queryset_var
else:
page_suffix = ''
Expand Down Expand Up @@ -170,15 +174,15 @@ def render(self, context):
'False, an HTTP 404 page would have been shown instead.')
context[key] = []
context['invalid_page'] = True
return u''
return ''
if self.context_var is not None:
context[self.context_var] = page_obj.object_list
else:
context[key] = page_obj.object_list
context['paginator'] = paginator
context['page_obj'] = page_obj
context['page_suffix'] = page_suffix
return u''
return ''


class PaginateNode(Node):
Expand Down Expand Up @@ -264,7 +268,7 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN):
paginator = context['paginator']
page_obj = context['page_obj']
page_suffix = context.get('page_suffix', '')
page_range = paginator.page_range
page_range = list(paginator.page_range)
# Calculate the record range in the current page for display.
records = {'first': 1 + (page_obj.number - 1) * paginator.per_page}
records['last'] = records['first'] + paginator.per_page - 1
Expand All @@ -280,7 +284,7 @@ def paginate(context, window=DEFAULT_WINDOW, margin=DEFAULT_MARGIN):
window_end = window_end - window_start
window_start = 0
if window_end > paginator.num_pages:
window_start = window_start - (window_end - paginator.num_pages)
window_start = max(0, window_start - (window_end - paginator.num_pages))
window_end = paginator.num_pages
pages = page_range[window_start:window_end]

Expand Down
Loading

0 comments on commit 5432e8f

Please sign in to comment.