From b70e74defad265d28c3e1048dcf294b3c7591adf Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Thu, 23 Jul 2015 16:36:04 -0300 Subject: [PATCH] Prepare ListView for custom pagination range --- sapl/crud.py | 8 ++++++++ templates/comissoes/comissao_list.html | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/sapl/crud.py b/sapl/crud.py index e352290ea..1d6f9b9b5 100644 --- a/sapl/crud.py +++ b/sapl/crud.py @@ -78,6 +78,14 @@ def build_crud(model, *layout): title = BaseMixin.verbose_name_plural paginate_by = 10 + def get_context_data(self, **kwargs): + context_data = super(CrudListView, self).get_context_data(**kwargs) + paginator = context_data['paginator'] + # TODO set custom_page_range to something like + # [1, 2, None, 10, 11, 12, None, 29, 30] + context_data['custom_page_range'] = paginator.page_range + return context_data + class CrudCreateView(BaseMixin, FormMessagesMixin, CreateView): form_class = crud.model_form title = _('Adicionar %(verbose_name)s') % { diff --git a/templates/comissoes/comissao_list.html b/templates/comissoes/comissao_list.html index 81b31034c..3ea7cc914 100644 --- a/templates/comissoes/comissao_list.html +++ b/templates/comissoes/comissao_list.html @@ -43,9 +43,9 @@
  • «
  • {% endif %} - {% for page in paginator.page_range %} + {% for page in custom_page_range %}
  • - {{ page }} + {% if page %}{{ page }}{% else %}…{% endif %}
  • {% endfor %}