Skip to content

Commit

Permalink
Merge pull request #22 from vikingco/story/TFD-379/remove-dependency-…
Browse files Browse the repository at this point in the history
…to-mvne

Removed mvne code.
  • Loading branch information
Waelburgs-Kevin authored Mar 16, 2017
2 parents b6ae8d2 + 96d4654 commit 5e668bb
Show file tree
Hide file tree
Showing 9 changed files with 94 additions and 240 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ pip-log.txt
# i18n db
.django.po-backup*
.djangojs.po-backup*

# pycharm configuration
.idea
17 changes: 6 additions & 11 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ DEPENDENCIES:
1. Pagination
-------------

In settings.py, configure the styling of the paginator, and add this application:
In settings.py, add this application:

> PAGINATOR_STYLE = 'glossyp' # 'glossyp' or 'digg'
> INSTALLED_APPS += ('django_ajax',)


The default styling just renders previous and next buttons. If you want links to more pages rendered, add this setting:

> PAGINATION_STYLE = 'verbose'


In views.py

> from django_ajax.pagination import paginate
Expand Down Expand Up @@ -82,15 +86,6 @@ ordering column headers. Place the links in a container, classnamed
> </div>


It is also possible to override te style defined in the settings.py, by
defining it in the {% paginate %} template tag. (Add style="digg" or
style="glossyp")

> {% paginate paginated_objects style="digg" %}
> ...
> {% endpaginate %}


The search results of a GET form can be retreived through AJAX, similar to
loading any other page. The form should have action="?" and method="get"
parameters. When enter has been pressed in this form, only the body of the paginator
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='django-ajax-utilities',
version='1.2.3',
version='2.0.0',
url='https://github.com/vikingco/django-ajax-utilities',
license='BSD',
description='Pagination, xhr and tabbing utilities for the Django framework.',
Expand Down
5 changes: 3 additions & 2 deletions src/django_ajax/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@


class Paginator(object):
def __init__(self, object_list, per_page, allow_empty_first_page=True, object_count=None):
def __init__(self, object_list, per_page, page_variable, allow_empty_first_page=True, object_count=None):
self.object_list = object_list
self.per_page = per_page
self.page_variable = page_variable
self.allow_empty_first_page = allow_empty_first_page
self._count = object_count
self._num_pages = None
Expand Down Expand Up @@ -121,7 +122,7 @@ def paginate(request,
Paginate an object list. Wrapper around the Django paginator.
"""

paginator = Paginator(object_list, num_per_page, object_count=object_count)
paginator = Paginator(object_list, num_per_page, object_count=object_count, page_variable=page_variable)

# Page number?
page_num = request.GET.get(page_variable, None)
Expand Down
43 changes: 0 additions & 43 deletions src/django_ajax/templates/pagination/bootstrap-style.html

This file was deleted.

28 changes: 0 additions & 28 deletions src/django_ajax/templates/pagination/glossyp-style.html

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
{% load i18n macro call %}
{% load i18n macro pagination %}

{% macro "header" %}
<div class="pagination{% if preload %} pagination_preload{% endif %}">
{% ifnotequal total 1 %}
{% if total > 1 %}
<strong>{% trans "Pages:" %}</strong>
{% if prev_page %}
<a class="prev" href="{{ request.path }}{% call query_string prev_page %}">&laquo; {% trans "previous" %}</a>
<a class="prev" href="{{ request.path }}{% paginated_querystring page_variable prev_page %}">&laquo; {% trans "previous" %}</a>
{% endif %}

{% for page_index in page_range %}
{% if not page_index %}
...
{% else %}
{% ifequal page_index current %}
{% if page_index == current %}
<span class="current">{{ page_index }}</span>
{% else %}
<a
{% ifequal page_index prev_page %}
class="prev"
{% else %}{% ifequal page_index next_page %}
class="next"
{% endifequal %}{% endifequal %}
href="{{ request.path }}{% call query_string page_index %}">{{ page_index }}</a>
{% endifequal %}
<a {% if page_index == prev_page %}class="prev"{% elif page_index == next_page %}class="next"{% endif %} href="{{ request.path }}{% paginated_querystring page_variable page_index %}">{{ page_index }}</a>
{% endif %}
{% endif %}
{% endfor %}

{% if next_page %}
<a class="next" href="{{ request.path }}{% call query_string next_page %}">{% trans "next" %} &raquo;</a>
<a class="next" href="{{ request.path }}{% paginated_querystring page_variable next_page %}">{% trans "next" %} &raquo;</a>
{% endif %}
{% endifnotequal %}
{% endif %}
</div>
{% endmacro %}

Expand Down
27 changes: 27 additions & 0 deletions src/django_ajax/templates/pagination/paginate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% load macro i18n pagination %}

{% macro "header" %}
{% if total > 1 %}
<div class="pagination{% if preload %} pagination_preload{% endif %}"><p>
{% if prev_page %}
<a class="prev more-link" href="{{ request.path }}{% paginated_querystring page_variable prev_page %}">&laquo; {% trans "previous" %}</a>
{% endif %}
{% blocktrans %}Page <strong>{{ current }}</strong> of <strong>{{ total }}</strong>{% endblocktrans %}
{% if next_page %}
<a class="next more-link" href="{{ request.path }}{% paginated_querystring page_variable next_page %}">{% trans "next" %} &raquo;</a>
{% endif %}
</p></div>
{% endif %}
{% endmacro %}


<div class="paginate-container paginate-glossyp-style">
{{ body|safe }}
{% callmacro "header" %}
</div>

<div class="paginate-loading" style="display: none; ">
<div style="margin: 50px;">
{% include "django-ajax/_loader.html" %}
</div>
</div>
Loading

0 comments on commit 5e668bb

Please sign in to comment.