This repository has been archived by the owner on Apr 17, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intial attempt at supporting bootstrap-v4 (alpha)
- Loading branch information
Showing
9 changed files
with
232 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
bootstrap_pagination/templates/bootstrap_pagination/pager-bs4.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<nav> | ||
<ul class="pager"> | ||
{% if page.has_previous %} | ||
<li{% if not centered %} class="pager-prev"{% endif %}> | ||
<a title="{{ previous_title }}" href="{{ previous_page_url|default:"#"|escape }}">{{ previous_label }}</a> | ||
</li> | ||
{% else %} | ||
<li class="{% if not centered %} pager-prev{% endif %} disabled"> | ||
<span title="{{ previous_title }}">{{ previous_label }}</span> | ||
</li> | ||
{% endif %} | ||
|
||
{% if page.has_next %} | ||
<li{% if not centered %} class="pager-next"{% endif %}> | ||
<a title="{{ next_title }}" href="{{ next_page_url|default:"#"|escape }}">{{ next_label }}</a> | ||
</li> | ||
{% else %} | ||
<li title="{{ next_title }}" class="{% if not centered %} pager-next{% endif %} disabled"> | ||
<span>{{ next_label }}</span> | ||
</li> | ||
{% endif %} | ||
</ul> | ||
</nav> |
File renamed without changes.
76 changes: 76 additions & 0 deletions
76
bootstrap_pagination/templates/bootstrap_pagination/pagination-bs4.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{% load bootstrap_pagination %} | ||
<nav> | ||
<ul class="pagination{% if size == "small" %} pagination-sm{% endif %}{% if size == "large" %} pagination-lg{% endif %}{% block extra_classes %}{% endblock %}"> | ||
{% if show_first_last %} | ||
{% if not page.has_previous %} | ||
<li class="disabled page-item"> | ||
<span aria-hidden="true" title="First Page">{{ first_label }}</span> | ||
<span class="sr-only">First Page</span> | ||
</li> | ||
{% else %} | ||
<li class="page-item"> | ||
<a title="First Page" href="{{ first_page_url|default:"#"|escape }}"> | ||
<span aria-hidden="true">{{ first_label }}</span> | ||
<span class="sr-only">First Page</span> | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endif %} | ||
{% if show_prev_next %} | ||
{% if not page.has_previous %} | ||
<li class="disabled page-item"> | ||
<span aria-hidden="true" title="Previous Page">{{ previous_label }}</span> | ||
<span class="sr-only">Previous Page</span> | ||
</li> | ||
{% else %} | ||
<li class="page-item"> | ||
<a title="Previous Page" href="{{ previous_page_url|default:"#"|escape }}"> | ||
<span aria-hidden="true">{{ previous_label }}</span> | ||
<span class="sr-only">Previous Page</span> | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endif %} | ||
{% for pagenum, index_range, url in page_urls %} | ||
{% if page.number == pagenum %} | ||
<li class="active"> | ||
<span title="Current Page">{% if show_index_range %} {{ index_range }} {% else %} {{ pagenum }} {%endif %}</span> | ||
</li> | ||
{% else %} | ||
<li class="page-item"> | ||
<a title="Page {{ pagenum }} of {{ page.paginator.num_pages }}" href="{{ url|escape }}">{% if show_index_range %} {{ index_range }} {% else %} {{ pagenum }} {%endif %}</a> | ||
</li> | ||
{% endif %} | ||
{% endfor %} | ||
{% if show_prev_next %} | ||
{% if not page.has_next %} | ||
<li class="disabled page-item"> | ||
<span aria-hidden="true" title="Next Page">{{ next_label }}</span> | ||
<span class="sr-only">Next Page</span> | ||
</li> | ||
{% else %} | ||
<li class="page-item"> | ||
<a title="Next Page" href="{{ next_page_url|default:"#"|escape }}"> | ||
<span aria-hidden="true">{{ next_label }}</span> | ||
<span class="sr-only">Next Page</span> | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endif %} | ||
{% if show_first_last %} | ||
{% if not page.has_next %} | ||
<li class="disabled page-item"> | ||
<span aria-hidden="true" title="Last Page">{{ last_label }}</span> | ||
<span class="sr-only">Last Page</span> | ||
</li> | ||
{% else %} | ||
<li class="page-item"> | ||
<a title="Last Page" href="{{ last_page_url|default:"#"|escape }}"> | ||
<span aria-hidden="true">{{ last_label }}</span> | ||
<span class="sr-only">Last Page</span> | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endif %} | ||
</ul> | ||
</nav> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
from functools import wraps | ||
|
||
from django.conf import UserSettingsHolder, settings | ||
try: | ||
from django.test.signals import setting_changed | ||
except ImportError: | ||
setting_changed = None | ||
|
||
|
||
# This was taken from django 1.9 django.tests.utils, and adapted to be | ||
# compatible with a wider range of django versions. | ||
class override_settings(object): | ||
""" | ||
Acts as either a decorator, or a context manager. If it's a decorator it | ||
takes a function and returns a wrapped function. If it's a contextmanager | ||
it's used with the ``with`` statement. In either event entering/exiting | ||
are called before and after, respectively, the function/block is executed. | ||
""" | ||
def __init__(self, **kwargs): | ||
self.options = kwargs | ||
|
||
def __enter__(self): | ||
self.enable() | ||
|
||
def __exit__(self, exc_type, exc_value, traceback): | ||
self.disable() | ||
|
||
def __call__(self, test_func): | ||
@wraps(test_func) | ||
def inner(*args, **kwargs): | ||
with self: | ||
return test_func(*args, **kwargs) | ||
return inner | ||
|
||
def save_options(self, test_func): | ||
if test_func._overridden_settings is None: | ||
test_func._overridden_settings = self.options | ||
else: | ||
# Duplicate dict to prevent subclasses from altering their parent. | ||
test_func._overridden_settings = dict( | ||
test_func._overridden_settings, **self.options) | ||
|
||
def enable(self): | ||
# Changing installed apps cannot be done in a backward-compatible way | ||
assert 'INSTALLED_APPS' not in self.options | ||
|
||
override = UserSettingsHolder(settings._wrapped) | ||
for key, new_value in self.options.items(): | ||
setattr(override, key, new_value) | ||
self.wrapped = settings._wrapped | ||
settings._wrapped = override | ||
for key, new_value in self.options.items(): | ||
if setting_changed: | ||
setting_changed.send(sender=settings._wrapped.__class__, | ||
setting=key, value=new_value, enter=True) | ||
|
||
def disable(self): | ||
settings._wrapped = self.wrapped | ||
del self.wrapped | ||
for key in self.options: | ||
new_value = getattr(settings, key, None) | ||
if setting_changed: | ||
setting_changed.send(sender=settings._wrapped.__class__, | ||
setting=key, value=new_value, enter=False) |