Skip to content

Commit

Permalink
Revert to django-tables2 1.2.6's pagination footer behavior, which in…
Browse files Browse the repository at this point in the history
…cludes a 'cardinality' section detailing item counts
  • Loading branch information
apocalyptech committed Dec 28, 2016
1 parent d8025b5 commit fad8747
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
- Change the display order of a few elements on the album download
page, and use an HTML ``<meta>`` tag to automatically queue up
the download, rather than only having the direct link.
- Override table footers to always include item counts, as was
present in ``django-tables2`` 1.2.6 but patched out in 1.2.7.

1.0.3 (2016-11-22)
------------------
Expand Down
1 change: 0 additions & 1 deletion exordium/templates/exordium/album_download.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{# vim: set syntax=htmldjango: #}
{% extends "exordium/album.html" %}
{% load render_table from django_tables2 %}

{% block extraheader %}
{% if zip_url and zip_file %}
Expand Down
2 changes: 1 addition & 1 deletion exordium/templates/exordium/album_info.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% load render_table from django_tables2 %}

{% block albumbody %}
{% render_table songs %}
{% render_table songs "exordium/table.html" %}
{% endblock %}
4 changes: 2 additions & 2 deletions exordium/templates/exordium/artist.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
{% load render_table from django_tables2 %}

{% block body %}
{% render_table albums %}
{% render_table albums "exordium/table.html" %}

{% if have_songs %}
<h2>Songs by {{ artist }}</h2>
{% render_table songs %}
{% render_table songs "exordium/table.html" %}
{% endif %}

{% endblock %}
2 changes: 1 addition & 1 deletion exordium/templates/exordium/browse.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
{% load render_table from django_tables2 %}

{% block body %}
{% render_table table %}
{% render_table table "exordium/table.html" %}
{% endblock %}
2 changes: 1 addition & 1 deletion exordium/templates/exordium/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
{% block body %}
<p>Welcome to Exordium!</p>
<h3>Recently-Added Albums</h3>
{% render_table album_list %}
{% render_table album_list "exordium/table.html" %}
{% endblock %}
6 changes: 3 additions & 3 deletions exordium/templates/exordium/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@

{% if artist_results %}
<h3>Artists</h3>
{% render_table artist_results %}
{% render_table artist_results "exordium/table.html" %}
{% endif %}

{% if album_results %}
<h3>Albums</h3>
{% render_table album_results %}
{% render_table album_results "exordium/table.html" %}
{% endif %}

{% if song_results %}
<h3>Songs</h3>
{% render_table song_results %}
{% render_table song_results "exordium/table.html" %}
{% endif %}

{% else %}
Expand Down
47 changes: 47 additions & 0 deletions exordium/templates/exordium/table.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{# vim: set syntax=htmldjango: #}
{% extends "django_tables2/table.html" %}
{% comment %}
django-tables 1.2.7 introduced some changes to their pagination
footer which I wasn't fond of (specifically they got rid of the
"X of Y item(s)" text). This custom template just overrides that
block to revert back to 1.2.6 behavior.
Since I want to implement a pagination system which lets you go
directly to various page numbers anyway, it'll be nice to have
this in place...
{% endcomment %}
{% load django_tables2 %}
{% load i18n %}

{% block pagination %}
<ul class="pagination">
{% if table.page.has_previous %}
{% block pagination.previous %}
<li class="previous">
<a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}">{% trans "Previous" %}</a>
</li>
{% endblock pagination.previous %}
{% endif %}

{% if table.page.has_previous or table.page.has_next %}
{% block pagination.current %}
<li class="current">
{% blocktrans with table.page.number as current and table.paginator.num_pages as total %}Page {{ current }} of {{ total }}{% endblocktrans %}
</li>
{% endblock pagination.current %}
{% endif %}

{% if table.page.has_next %}
{% block pagination.next %}
<li class="next">
<a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}">{% trans "Next" %}</a>
</li>
{% endblock pagination.next %}
{% endif %}
{% block pagination.cardinality %}
<li class="cardinality">
{% if total != count %}{% blocktrans %}{{ count }} of {{ total }}{% endblocktrans %}{% else %}{{ total }}{% endif %} {% if total == 1 %}{{ table.data.verbose_name }}{% else %}{{ table.data.verbose_name_plural }}{% endif %}
</li>
{% endblock pagination.cardinality %}
</ul>
{% endblock pagination %}

0 comments on commit fad8747

Please sign in to comment.