Commit a1fd50bd authored by Aurélien Bompard's avatar Aurélien Bompard

Use the paginator from django_mailman3

parent e564529d
......@@ -21,16 +21,5 @@
*/
$(function() {
/* Pagination */
$(".pager .pager-select a").click(function(e) {
e.preventDefault();
$(this).hide();
$(this).next("form").removeClass("hidden");
});
$(".pager .pager-select form select").change(function() {
$(this).closest("form").submit();
});
});
// $(function() {
// });
......@@ -117,6 +117,7 @@
<script src="{% static 'postorius/libs/jquery/jquery-1.11.3.min.js' %}"></script>
<script src="{% static 'postorius/libs/bootstrap/js/bootstrap.min.js' %}"></script>
<script src="{% static 'django-mailman3/js/main.js' %}"></script>
<script src="{% static 'postorius/js/script.js' %}"></script>
{% block additionaljs %}{% endblock %}
</body>
......
{% extends postorius_base_template %}
{% load i18n %}
{% load pagination %}
{% block head_title %}
{% trans 'List Index' %} - {{ block.super }}
......@@ -47,7 +48,7 @@
{% if user.is_superuser %}
<small>* {% trans 'Only admins see unadvertised lists in the list index.' %}</small>
{% endif %}
{% include 'postorius/lib/pagination.html' with page=lists %}
{% paginator lists %}
{% else %}
<p>{% trans 'There are currently no mailing lists.' %}</p>
{% endif %}
......
{% load i18n %}
{% load pagination %}
{% if page.paginator.num_pages > 1 %}
<nav class="text-center">
{% if page.paginator.num_pages > 10 %}
<ul class="pager">
{% if page.has_previous %}
<li class="col-md-4 text-right">
<a href="?{% add_to_query_string page=page.previous_page_number count=page.paginator.per_page %}">&larr; {% trans 'Previous' %}</a>
</li>
{% else %}
<li class="disabled col-md-4 text-right"><span>&larr; {% trans 'Previous' %}</span></li>
{% endif %}
<li class="pager-select col-md-4">
<a href="">{% blocktrans with num=page.number total=page.paginator.num_pages %}Page {{ num }} of {{ total }}{% endblocktrans %}</a>
<form class="form-inline hidden" action="" method="GET">
<label>
{% trans 'Jump to page:' %}
<select class="form-control input-sm" name="page">
{% for pagenum in page.paginator.page_range %}
<option value="{{ pagenum }}"
{% if page.number == pagenum %}selected{% endif %}>
{{ pagenum }}
</option>
{% endfor %}
</select>
</label>
{% for key, value in request.GET.items %}
{% if key != 'page' %}
<input type="hidden" name="{{ key }}" value="{{ value }}" />
{% endif %}
{% endfor %}
</form>
</li>
{% if page.has_next %}
<li class="col-md-4 text-left">
<a href="?{% add_to_query_string page=page.next_page_number count=page.paginator.per_page %}">{% trans 'Next' %} &rarr;</a>
</li>
{% else %}
<li class="disabled col-md-4 text-left"><span>{% trans 'Next' %} &rarr;</span></li>
{% endif %}
</ul>
{% else %}
<ul class="pagination">
{% if page.has_previous %}
<li>
<a href="?{% add_to_query_string page=page.previous_page_number count=page.paginator.per_page %}">&laquo;</a>
</li>
{% else %}
<li class="disabled"><span>&laquo;</span></li>
{% endif %}
{% for pagenum in page.paginator.page_range %}
{% if page.number == pagenum %}
<li class="active"><span>{{ pagenum }}</span></li>
{% else %}
<li><a href="?{% add_to_query_string page=pagenum count=page.paginator.per_page %}">{{ pagenum }}</a></li>
{% endif %}
{% endfor %}
{% if page.has_next %}
<li><a href="?{% add_to_query_string page=page.next_page_number count=page.paginator.per_page %}">&raquo;</a></li>
{% else %}
<li class="disabled"><span>&raquo;</span></li>
{% endif %}
</ul>
{% endif %}
<form action="{{ request.path }}" method="get" class="form-inline">
<p class="text-center">
{% for key, value in request.GET.items %}
{% if key != 'count' %}
<input type="hidden" name="{{ key }}" value="{{ value }}" />
{% endif %}
{% endfor %}
{% trans 'Results per page:' %}
<select name="count" class="form-control input-sm">
{% for count in count_options %}
<option value="{{ count }}"
{% if page.paginator.per_page == count %}
selected="selected"
{% endif %}
>{{ count }}
</option>
{% endfor %}
</select>
<input type="submit" class="btn btn-default btn-sm" value="Update" />
</p>
</form>
</nav>
{% endif %}
{% extends postorius_base_template %}
{% load i18n %}
{% load nav_helpers %}
{% load pagination %}
{% load staticfiles %}
{% block head_title %}
......@@ -63,7 +64,7 @@
</table>
</div>
</form>
{% include 'postorius/lib/pagination.html' with page=held_messages %}
{% paginator held_messages %}
<div class="modal fade" id="held-messages-modal" tabindex="-1" role="dialog" aria-labelledby="mymodal-label" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
......
......@@ -2,6 +2,7 @@
{% load i18n %}
{% load bootstrap_tags %}
{% load nav_helpers %}
{% load pagination %}
{% block head_title %}
{% trans 'List members' %} | {{ list.fqdn_listname}} - {{ block.super }}
......@@ -90,7 +91,7 @@
</div>
{% if role == 'subscriber' %}
</form>
{% include 'postorius/lib/pagination.html' with page=members %}
{% paginator members %}
{% endif %}
{% else %}
<p>{{ empty_error }}</p>
......
......@@ -116,7 +116,6 @@ def list_members_view(request, list_id, role=None):
else:
context['empty_error'] =\
_('No member was found matching the search')
context['count_options'] = [25, 50, 100, 200]
context['form'] = form
else:
context['member_form'] = member_form
......@@ -433,7 +432,6 @@ def list_moderation(request, list_id, held_id=-1):
paginator_class=MailmanPaginator)
context = {
'list': mailing_list,
'count_options': [25, 50, 100, 200],
'held_messages': held_messages,
'form': form,
}
......@@ -559,7 +557,7 @@ def list_index(request, template='postorius/index.html'):
return utils.render_api_error(request)
choosable_domains = _get_choosable_domains(request)
return render(request, template,
{'count_options': [10, 25, 50, 100, 200], 'error': error,
{'error': error,
'lists': paginate(
lists, request.GET.get('page'),
request.GET.get('count', 10)),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment