mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 00:53:08 +00:00 
			
		
		
		
	Macro for pagination
This commit is contained in:
		| @@ -72,3 +72,23 @@ | |||||||
|     <a href="{{ url("core:user_godfathers_delete", user_id=profile.id, godfather_id=godfather.id, is_father=is_father) }}">{% trans %}Delete{% endtrans %}</a> |     <a href="{{ url("core:user_godfathers_delete", user_id=profile.id, godfather_id=godfather.id, is_father=is_father) }}">{% trans %}Delete{% endtrans %}</a> | ||||||
|     {% endif %} |     {% endif %} | ||||||
| {% endmacro %} | {% endmacro %} | ||||||
|  |  | ||||||
|  | {% macro paginate(page_obj, paginator) %} | ||||||
|  |         {% if page_obj.has_previous() %} | ||||||
|  |             <a href="?page={{ page_obj.previous_page_number() }}">{% trans %}Previous{% endtrans %}</a> | ||||||
|  |         {% else %} | ||||||
|  |             <span class="disabled">{% trans %}Previous{% endtrans %}</span> | ||||||
|  |         {% endif %} | ||||||
|  |     {% for i in paginator.page_range %} | ||||||
|  |         {% if page_obj.number == i %} | ||||||
|  |             <span class="active">{{ i }} <span class="sr-only">({% trans %}current{% endtrans %})</span></span> | ||||||
|  |         {% else %} | ||||||
|  |             <a href="?page={{ i }}">{{ i }}</a> | ||||||
|  |         {% endif %} | ||||||
|  |     {% endfor %} | ||||||
|  |     {% if page_obj.has_next() %} | ||||||
|  |         <a href="?page={{ page_obj.next_page_number() }}">{% trans %}Next{% endtrans %}</a> | ||||||
|  |     {% else %} | ||||||
|  |         <span class="disabled">{% trans %}Next{% endtrans %}</span> | ||||||
|  |     {% endif %} | ||||||
|  | {% endmacro %} | ||||||
| @@ -1,5 +1,5 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "core/base.jinja" %} | ||||||
| {% from 'core/macros.jinja' import user_profile_link %} | {% from 'core/macros.jinja' import user_profile_link, paginate %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| {% trans %}Cash register summary list{% endtrans %} | {% trans %}Cash register summary list{% endtrans %} | ||||||
| @@ -57,23 +57,7 @@ | |||||||
| </table> | </table> | ||||||
| <br> | <br> | ||||||
| {% if is_paginated %} | {% if is_paginated %} | ||||||
|         {% if page_obj.has_previous() %} |     {{ paginate(page_obj, paginator) }} | ||||||
|             <a href="?page={{ page_obj.previous_page_number() }}">{% trans %}Previous{% endtrans %}</a> |  | ||||||
|         {% else %} |  | ||||||
|             <span class="disabled">{% trans %}Previous{% endtrans %}</span> |  | ||||||
|         {% endif %} |  | ||||||
|     {% for i in paginator.page_range %} |  | ||||||
|         {% if page_obj.number == i %} |  | ||||||
|             <span class="active">{{ i }} <span class="sr-only">({% trans %}current{% endtrans %})</span></span> |  | ||||||
|         {% else %} |  | ||||||
|             <a href="?page={{ i }}">{{ i }}</a> |  | ||||||
|         {% endif %} |  | ||||||
|     {% endfor %} |  | ||||||
|     {% if page_obj.has_next() %} |  | ||||||
|         <a href="?page={{ page_obj.next_page_number() }}">{% trans %}Next{% endtrans %}</a> |  | ||||||
|     {% else %} |  | ||||||
|         <span class="disabled">{% trans %}Next{% endtrans %}</span> |  | ||||||
|     {% endif %} |  | ||||||
| {% endif %} | {% endif %} | ||||||
| {% else %} | {% else %} | ||||||
| {% trans %}There is no cash register summary in this website.{% endtrans %} | {% trans %}There is no cash register summary in this website.{% endtrans %} | ||||||
|   | |||||||
| @@ -1,4 +1,5 @@ | |||||||
| {% extends "core/base.jinja" %} | {% extends "core/base.jinja" %} | ||||||
|  | {% from 'core/macros.jinja' import paginate %} | ||||||
|  |  | ||||||
| {% block title %} | {% block title %} | ||||||
| {%- trans %}Election list{% endtrans %} | {%- trans %}Election list{% endtrans %} | ||||||
| @@ -44,5 +45,8 @@ | |||||||
|     <p>{{ election.description }}</p> |     <p>{{ election.description }}</p> | ||||||
|   </section> |   </section> | ||||||
|   {%- endfor %} |   {%- endfor %} | ||||||
|  | {% if is_paginated %} | ||||||
|  |     {{ paginate(page_obj, paginator) }} | ||||||
|  | {% endif %} | ||||||
| {%- endblock %} | {%- endblock %} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -164,6 +164,8 @@ class ElectionsListView(CanViewMixin, ListView): | |||||||
|     A list with all responsabilities and their candidates |     A list with all responsabilities and their candidates | ||||||
|     """ |     """ | ||||||
|     model = Election |     model = Election | ||||||
|  |     ordering = ["-id"] | ||||||
|  |     paginate_by = 10 | ||||||
|     template_name = 'election/election_list.jinja' |     template_name = 'election/election_list.jinja' | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user