Change date format in month pagination

This commit is contained in:
Edgar P. Burkhart 2024-01-02 15:00:27 +01:00
parent 2ba21fbd10
commit f8c0f9dced
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 7 additions and 5 deletions

View file

@ -11,11 +11,11 @@
<p class="pagination">{% year_url month %}</p> <p class="pagination">{% year_url month %}</p>
<p class="pagination n3"> <p class="pagination n3">
{% if previous_month %} {% if previous_month %}
{% month_url previous_month %} {% month_url previous_month fmt="F Y" %}
{% endif %} {% endif %}
{% month_url month cls="cur" %} {% month_url month cls="cur" fmt="F Y" %}
{% if next_month %} {% if next_month %}
{% month_url next_month %} {% month_url next_month fmt="F Y" %}
{% endif %} {% endif %}
</p> </p>
{% endif %} {% endif %}

View file

@ -11,13 +11,15 @@ register = template.Library()
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)
def month_url(context, month, cls=""): def month_url(context, month, cls="", fmt="Y-m"):
url_name, url_params = ac_url( url_name, url_params = ac_url(
"transaction_month", {"year": month.year, "month": month.month}, context "transaction_month", {"year": month.year, "month": month.month}, context
) )
url = reverse(url_name, kwargs=url_params) url = reverse(url_name, kwargs=url_params)
return mark_safe(f"""<a class="{cls}" href="{url}">{ date(month, "Y-m") }</a>""") return mark_safe(
f"""<a class="{cls}" href="{url}">{date(month, fmt).capitalize()}</a>"""
)
@register.simple_tag(takes_context=True) @register.simple_tag(takes_context=True)