diff --git a/src/postorius/static/postorius/css/style.css b/src/postorius/static/postorius/css/style.css index 29acf1b..04c2f9b 100755 --- a/src/postorius/static/postorius/css/style.css +++ b/src/postorius/static/postorius/css/style.css @@ -307,3 +307,7 @@ .well .archival-options-form li { display: block; } + +.hidden { + display: none; +} diff --git a/src/postorius/static/postorius/js/script.js b/src/postorius/static/postorius/js/script.js index e69de29..2c2d364 100755 --- a/src/postorius/static/postorius/js/script.js +++ b/src/postorius/static/postorius/js/script.js @@ -0,0 +1,36 @@ +/* + * Postorius + * + * Copyright (C) 1998-2015 by the Free Software Foundation, Inc. + * + * This file is part of Postorius. + * + * Postorius is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Postorius is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * Postorius. If not, see . + * + */ + + +$(function() { + + /* Pagination */ + $(".pager .pager-select a").click(function(e) { + e.preventDefault(); + $(this).hide(); + $(this).next("form").css("display", "inline-block"); + }); + $(".pager .pager-select form select").change(function() { + $(this).closest("form").submit(); + }); + +}); diff --git a/src/postorius/templates/postorius/_pagination.html b/src/postorius/templates/postorius/_pagination.html new file mode 100644 index 0000000..9860969 --- /dev/null +++ b/src/postorius/templates/postorius/_pagination.html @@ -0,0 +1,59 @@ +{% load url from future %} +{% load i18n %} + +{% if page.paginator.num_pages > 1 %} + +{% endif %} diff --git a/src/postorius/templates/postorius/base.html b/src/postorius/templates/postorius/base.html index 80acfcc..c546c0b 100644 --- a/src/postorius/templates/postorius/base.html +++ b/src/postorius/templates/postorius/base.html @@ -65,5 +65,6 @@ + {% block additionaljs %}{% endblock %} diff --git a/src/postorius/templates/postorius/lists/index.html b/src/postorius/templates/postorius/lists/index.html index 01efa94..a4224e5 100644 --- a/src/postorius/templates/postorius/lists/index.html +++ b/src/postorius/templates/postorius/lists/index.html @@ -34,13 +34,15 @@ {% for list in lists %} + {% with settings=list.settings %} - {{ list.display_name }}{% if not list.settings.advertised %} ({% trans 'unadvertised' %}*){% endif %} + {{ list.display_name }}{% if not settings.advertised %} ({% trans 'unadvertised' %}*){% endif %} {{ list.fqdn_listname }} - {{ list.settings.description }} + {{ settings.description }} + {% endwith %} {% endfor %} @@ -49,6 +51,8 @@ * {% trans 'Only admins see unadvertised lists in the list index.' %} {% endif %} + {% include 'postorius/_pagination.html' with page=lists %} + {% else %}

There are currently no mailing lists.

diff --git a/src/postorius/views/list.py b/src/postorius/views/list.py index 3b63d3a..0104aa6 100644 --- a/src/postorius/views/list.py +++ b/src/postorius/views/list.py @@ -30,6 +30,7 @@ from django.core.exceptions import ValidationError from django.utils.decorators import method_decorator from django.utils.translation import gettext as _ +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger try: from urllib2 import HTTPError except ImportError: @@ -468,26 +469,39 @@ def list_index(request, template='postorius/lists/index.html'): """Show a table of all public mailing lists. """ + if request.method == 'POST': + return redirect("list_summary", list_id=request.POST["list"]) lists = [] error = None only_public = True if request.user.is_superuser: only_public = False try: - lists = List.objects.all(only_public=only_public) + lists = sorted(List.objects.all(only_public=only_public), + key=lambda l: l.fqdn_listname) logger.debug(lists) except MailmanApiError: return utils.render_api_error(request) + + # Paginate + paginator = Paginator(lists, 15) # Show 15 lists per page + page = request.GET.get('page') + try: + lists = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + lists = paginator.page(1) + except EmptyPage: + # If page is out of range (e.g. 9999), deliver last page of results. + lists = paginator.page(paginator.num_pages) + choosable_domains = _get_choosable_domains(request) - if request.method == 'POST': - return redirect("list_summary", list_id=request.POST["list"]) - else: - return render_to_response( - template, { - 'error': error, - 'lists': sorted(lists, key=lambda l: l.fqdn_listname), - 'domain_count': len(choosable_domains), - }, context_instance=RequestContext(request)) + return render_to_response( + template, { + 'error': error, + 'lists': lists, + 'domain_count': len(choosable_domains), + }, context_instance=RequestContext(request)) @login_required