Browse Source

Prepare ListView for custom pagination range

pull/6/head
Marcio Mazza 10 years ago
parent
commit
b70e74defa
  1. 8
      sapl/crud.py
  2. 4
      templates/comissoes/comissao_list.html

8
sapl/crud.py

@ -78,6 +78,14 @@ def build_crud(model, *layout):
title = BaseMixin.verbose_name_plural title = BaseMixin.verbose_name_plural
paginate_by = 10 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): class CrudCreateView(BaseMixin, FormMessagesMixin, CreateView):
form_class = crud.model_form form_class = crud.model_form
title = _('Adicionar %(verbose_name)s') % { title = _('Adicionar %(verbose_name)s') % {

4
templates/comissoes/comissao_list.html

@ -43,9 +43,9 @@
<li class="arrow unavailable"><a href="">&laquo;</a></li> <li class="arrow unavailable"><a href="">&laquo;</a></li>
{% endif %} {% endif %}
{% for page in paginator.page_range %} {% for page in custom_page_range %}
<li {% if page == page_obj.number %}class="active current"{% endif %}> <li {% if page == page_obj.number %}class="active current"{% endif %}>
<a href="?page={{ page }}">{{ page }}</a> <a href="?page={{ page }}">{% if page %}{{ page }}{% else %}&hellip;{% endif %}</a>
</li> </li>
{% endfor %} {% endfor %}

Loading…
Cancel
Save