1461: Этап №5: Фильтрация событий

сделан вывод GET параметров для пагинатора
remotes/origin/stage5
Alexander Burdeiny 10 years ago
parent 94f80ee858
commit 62fa8f709e
  1. 7
      events/views.py
  2. 8
      templates/client/events/filter_listview.html
  3. 2
      templates/client/events/filter_listview_ajax.html
  4. 45
      templates/client/includes/events/paginator.html

@ -35,6 +35,13 @@ class FilterListView(ContextMixin, FormMixin, ListView):
def get(self, request, *args, **kwargs):
self.form = self.get_form(self.get_form_class())
self.extra_ctx['form'] = self.form
# get params for paginator
get = request.GET.copy()
if 'page' in get:
del get[key]
self.extra_ctx['GETparams'] = get.urlencode()
# ajax or get
self.template_name = self._template_name_ajax if request.is_ajax() else self._template_name
return super(FilterListView, self).get(request, *args, **kwargs)

@ -33,9 +33,7 @@
{% endblock %}
{% block paginator %}
{% with page_obj=page_obj queries=queries %}
{% include 'client/includes/search_paginator.html' %}
{% endwith %}
{% with page_obj=page_obj queries=queries %}
{% include 'client/includes/events/paginator.html' %}
{% endwith %}
{% endblock %}

@ -20,6 +20,6 @@
{% block paginator %}
{% with page_obj=page_obj queries=queries %}
{% include 'client/includes/search_paginator.html' %}
{% include 'client/includes/events/paginator.html' %}
{% endwith %}
{% endblock %}

@ -0,0 +1,45 @@
{% load i18n %}
{% load template_filters %}
{% if page_obj.paginator.num_pages > 1 %}
<div class="pagination clearfix">
<div class="pg-info"> {% trans 'Показано' %} {{ page_obj.start_index }} - {{ page_obj.end_index }} <i>({% trans 'всего' %} {{ page_obj.paginator.count }} {% trans 'позиций' %})</i></div>
<div class="pg-body">
{% if page_obj.has_previous %}
<a class="pg-prev" href="?page={{ page_obj.previous_page_number }}&{{ GETparams }}">{% trans 'Предыдущая' %}</a>
{% else %}
<a class="pg-prev disabled" href="#">{% trans 'Предыдущая' %}</a>
{% endif %}
<ul>
{% if page_obj.number > 2 %}
<li><a href="?page={{ 1 }}&{{ GETparams }} ">{{ 1 }}</a></li>
{% if page_obj.number > 3 %}
<li>...</li>
{% endif %}
{% endif %}
{% if page_obj.has_previous %}
<li><a href="?page={{ page_obj.previous_page_number }}&{{ GETparams }}">{{ page_obj.previous_page_number }}</a></li>
{% endif %}
<li><b>{{ page_obj.number }}</b></li>
{% if page_obj.has_next %}
<li><a href="?page={{ page_obj.next_page_number }}&{{ GETparams }}">{{ page_obj.next_page_number }}</a></li>
{% endif %}
{% if page_obj.paginator.num_pages|subtract:page_obj.number > 1 %}
{% if page_obj.paginator.num_pages|subtract:page_obj.number > 2 %}
<li>...</li>
{% endif %}
<li><a href="?page={{ page_obj.paginator.num_pages }}&{{ GETparams }}">{{ page_obj.paginator.num_pages }}</a></li>
{% endif %}
</ul>
{% if page_obj.has_next %}
<a class="pg-next" href="?page={{ page_obj.next_page_number }}&{{ GETparams }}">{% trans 'Следующая' %}</a>
{% else %}
<a class="pg-next disabled" href="#">{% trans 'Следующая' %}</a>
{% endif %}
</div>
</div>
{% endif %}
Loading…
Cancel
Save