diff --git a/core/templates/core/macros.jinja b/core/templates/core/macros.jinja
index 244617c5..9be68685 100644
--- a/core/templates/core/macros.jinja
+++ b/core/templates/core/macros.jinja
@@ -72,3 +72,23 @@
{% trans %}Delete{% endtrans %}
{% endif %}
{% endmacro %}
+
+{% macro paginate(page_obj, paginator) %}
+ {% if page_obj.has_previous() %}
+ {% trans %}Previous{% endtrans %}
+ {% else %}
+ {% trans %}Previous{% endtrans %}
+ {% endif %}
+ {% for i in paginator.page_range %}
+ {% if page_obj.number == i %}
+ {{ i }} ({% trans %}current{% endtrans %})
+ {% else %}
+ {{ i }}
+ {% endif %}
+ {% endfor %}
+ {% if page_obj.has_next() %}
+ {% trans %}Next{% endtrans %}
+ {% else %}
+ {% trans %}Next{% endtrans %}
+ {% endif %}
+{% endmacro %}
\ No newline at end of file
diff --git a/counter/templates/counter/cash_summary_list.jinja b/counter/templates/counter/cash_summary_list.jinja
index a9432d06..80f80f81 100644
--- a/counter/templates/counter/cash_summary_list.jinja
+++ b/counter/templates/counter/cash_summary_list.jinja
@@ -1,5 +1,5 @@
{% extends "core/base.jinja" %}
-{% from 'core/macros.jinja' import user_profile_link %}
+{% from 'core/macros.jinja' import user_profile_link, paginate %}
{% block title %}
{% trans %}Cash register summary list{% endtrans %}
@@ -57,23 +57,7 @@
{% if is_paginated %}
- {% if page_obj.has_previous() %}
- {% trans %}Previous{% endtrans %}
- {% else %}
- {% trans %}Previous{% endtrans %}
- {% endif %}
- {% for i in paginator.page_range %}
- {% if page_obj.number == i %}
- {{ i }} ({% trans %}current{% endtrans %})
- {% else %}
- {{ i }}
- {% endif %}
- {% endfor %}
- {% if page_obj.has_next() %}
- {% trans %}Next{% endtrans %}
- {% else %}
- {% trans %}Next{% endtrans %}
- {% endif %}
+ {{ paginate(page_obj, paginator) }}
{% endif %}
{% else %}
{% trans %}There is no cash register summary in this website.{% endtrans %}
diff --git a/election/templates/election/election_list.jinja b/election/templates/election/election_list.jinja
index 3bcb0110..9e06eb74 100644
--- a/election/templates/election/election_list.jinja
+++ b/election/templates/election/election_list.jinja
@@ -1,4 +1,5 @@
{% extends "core/base.jinja" %}
+{% from 'core/macros.jinja' import paginate %}
{% block title %}
{%- trans %}Election list{% endtrans %}
@@ -44,5 +45,8 @@
{{ election.description }}
{%- endfor %} +{% if is_paginated %} + {{ paginate(page_obj, paginator) }} +{% endif %} {%- endblock %} diff --git a/election/views.py b/election/views.py index 47230338..80cc1499 100644 --- a/election/views.py +++ b/election/views.py @@ -164,6 +164,8 @@ class ElectionsListView(CanViewMixin, ListView): A list with all responsabilities and their candidates """ model = Election + ordering = ["-id"] + paginate_by = 10 template_name = 'election/election_list.jinja'