Skip to content

Commit

Permalink
Merge pull request #284 from nossas/hotfix/fixed-url-parameters-pagin…
Browse files Browse the repository at this point in the history
…ation

fix(vote): Fixed parameters on pagination actions
  • Loading branch information
igr-santos authored Sep 3, 2024
2 parents ff9dc08 + 024962c commit 287b12b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "votepeloclima/base.html" %}
{% load static crispy_forms_filters compress thumbnail %}
{% load static crispy_forms_filters url_tags compress thumbnail %}

{% block head_css %}
{{ block.super }}
Expand Down Expand Up @@ -76,7 +76,7 @@ <h5 class="text-uppercase fw-bold text-center">Infelizmente nenhuma candidatura
</div>
<ul class="pagination justify-content-end mt-3">
<li class="page-item{% if not page_obj.has_previous %} disabled{% endif %}">
<a class="page-link"{% if page_obj.has_previous %} href="?page={{ page_obj.previous_page_number }}"{% endif %}>
<a class="page-link"{% if page_obj.has_previous %} href="?{% url_replace page=page_obj.previous_page_number %}"{% endif %}>
<i class="ds-paginator-previous"></i>
</a>
</li>
Expand All @@ -86,14 +86,14 @@ <h5 class="text-uppercase fw-bold text-center">Infelizmente nenhuma candidatura
</span> -->
{% for page_number in page_obj.paginator.page_range %}
<li class="page-item{% if page_number == page_obj.number %} active{% endif %}">
<a class="page-link"{% if page_number != page_obj.number %} href="?page={{ page_number }}"{% endif %}>
<a class="page-link"{% if page_number != page_obj.number %} href="?{% url_replace page=page_number %}"{% endif %}>
{{ page_number }}
</a>
</li>
{% endfor %}

<li class="page-item{% if not page_obj.has_next %} disabled{% endif %}">
<a class="page-link"{% if page_obj.has_next %} href="?page={{ page_obj.next_page_number }}"{% endif %}>
<a class="page-link"{% if page_obj.has_next %} href="?{% url_replace page=page_obj.next_page_number %}"{% endif %}>
<i class="ds-paginator-next"></i>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django import template

register = template.Library()

@register.simple_tag(takes_context=True)
def url_replace(context, **kwargs):
query = context['request'].GET.copy()
for key in kwargs.keys():
if key in query:
del(query[key])
query.update(kwargs)
return query.urlencode()

0 comments on commit 287b12b

Please sign in to comment.