Refactor transaction archive templates

Fix 
This commit is contained in:
Edgar P. Burkhart 2025-01-05 09:43:29 +01:00
parent d5292911c2
commit 71f7a82f60
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
4 changed files with 85 additions and 48 deletions
nummi

View file

@ -2,26 +2,3 @@
{% if page_obj %}
<p class="pagination">{% pagination_links page_obj %}</p>
{% endif %}
{% if month %}
<p class="pagination">{% year_url month %}</p>
<p class="pagination n3">
{% if previous_month %}
{% month_url previous_month fmt="F Y" %}
{% endif %}
{% month_url month cls="cur" fmt="F Y" %}
{% if next_month %}
{% month_url next_month fmt="F Y" %}
{% endif %}
</p>
{% endif %}
{% if year %}
<p class="pagination n3">
{% if previous_year %}
{% year_url previous_year cls="prev" %}
{% endif %}
{% year_url year cls="cur" %}
{% if next_year %}
{% year_url next_year cls="next" %}
{% endif %}
</p>
{% endif %}

View file

@ -1,20 +1,37 @@
{% extends "transaction/transaction_list.html" %}
{% load i18n main_extras transaction_extras static category %}
{% extends "main/base.html" %}
{% load i18n static main_extras transaction_extras category %}
{% block link %}
{{ block.super }}
{% css "main/css/plot.css" %}
{% endblock %}
{% block name %}{{ month|date:"F Y"|capfirst }}{% endblock %}
{% block h2 %}{{ month|date:"F Y"|capfirst }}{% endblock %}
{% block backlinks %}
{{ block.super }}
{% css "main/css/table.css" %}
{% endblock link %}
{% block title %}
{{ year|date:"Y" }} {{ block.super }}
{% endblock title %}
{% block body %}
<h2>{{ month|date:"F Y"|capfirst }}</h2>
<p class="pagination">{% year_url month %}</p>
<p class="pagination n3">
{% if previous_month %}
{% month_url previous_month fmt="F Y" %}
{% endif %}
{% month_url month cls="cur" fmt="F Y" %}
{% if next_month %}
{% month_url next_month fmt="F Y" %}
{% endif %}
</p>
{% if account or category %}
<p class="back">
<a href="{% url "transaction_month" month.year month.month %}">{% translate "Back" %}{{ "arrow-go-back"|remix }}</a>
<a class="big-link"
href="{% url "transaction_month" month.year month.month %}">{{ "arrow-go-back"|remix }}{% translate "Back" %}</a>
{% if account %}
<a class="big-link" href="{% url "account" account.pk %}">{{ account.icon|remix }}{{ account }}</a>
{% endif %}
{% if category %}
<a class="big-link" href="{% url "category" category.pk %}">{{ category.icon|remix }}{{ category }}</a>
{% endif %}
</p>
{% endif %}
{% endblock %}
{% block table %}
{% if not category %}
<section>
<h3>{% translate "Categories" %}</h3>
@ -23,6 +40,20 @@
{% endif %}
<section>
<h3>{% translate "Transactions" %}</h3>
{{ block.super }}
{% url_get "transactions" start_date=month end_date=month|end_of_month category=category.id account=account.id as t_url %}
<p>
<a class="big-link" href="{{ t_url }}">{{ "list-check"|remixnl }}{% translate "View all transactions" %}</a>
</p>
{% transaction_table transactions n_max=8 transactions_url=t_url %}
</section>
{% endblock %}
<p class="pagination">{% year_url month %}</p>
<p class="pagination n3">
{% if previous_month %}
{% month_url previous_month fmt="F Y" %}
{% endif %}
{% month_url month cls="cur" fmt="F Y" %}
{% if next_month %}
{% month_url next_month fmt="F Y" %}
{% endif %}
</p>
{% endblock body %}

View file

@ -1,20 +1,35 @@
{% extends "transaction/transaction_list.html" %}
{% load i18n main_extras static category %}
{% extends "main/base.html" %}
{% load i18n static main_extras transaction_extras category %}
{% block link %}
{{ block.super }}
{% css "main/css/plot.css" %}
{% endblock %}
{% block name %}{{ year|date:"Y" }}{% endblock %}
{% block h2 %}{{ year|date:"Y" }}{% endblock %}
{% block backlinks %}
{{ block.super }}
{% css "main/css/table.css" %}
{% endblock link %}
{% block title %}
{{ year|date:"Y" }} {{ block.super }}
{% endblock title %}
{% block body %}
<h2>{{ year|date:"Y" }}</h2>
<p class="pagination n3">
{% if previous_year %}
{% year_url previous_year cls="prev" %}
{% endif %}
{% year_url year cls="cur" %}
{% if next_year %}
{% year_url next_year cls="next" %}
{% endif %}
</p>
{% if account or category %}
<p class="back">
<a href="{% url "transaction_year" year.year %}">{% translate "Back" %}{{ "arrow-go-back"|remix }}</a>
<a class="big-link" href="{% url "transaction_year" year.year %}">{{ "arrow-go-back"|remix }}{% translate "Back" %}</a>
{% if account %}
<a class="big-link" href="{% url "account" account.pk %}">{{ account.icon|remix }}{{ account }}</a>
{% endif %}
{% if category %}
<a class="big-link" href="{% url "category" category.pk %}">{{ category.icon|remix }}{{ category }}</a>
{% endif %}
</p>
{% endif %}
{% endblock %}
{% block table %}
{% if history %}
<section>
<h3>{% translate "History" %}</h3>
@ -29,6 +44,19 @@
{% endif %}
<section>
<h3>{% translate "Transactions" %}</h3>
{{ block.super }}
{% url_get "transactions" start_date=year end_date=year|end_of_year category=category.id account=account.id as t_url %}
<p>
<a class="big-link" href="{{ t_url }}">{{ "list-check"|remixnl }}{% translate "View all transactions" %}</a>
</p>
{% transaction_table transactions n_max=8 transactions_url=t_url %}
</section>
{% endblock %}
<p class="pagination n3">
{% if previous_year %}
{% year_url previous_year cls="prev" %}
{% endif %}
{% year_url year cls="cur" %}
{% if next_year %}
{% year_url next_year cls="next" %}
{% endif %}
</p>
{% endblock body %}

View file

@ -251,5 +251,6 @@ class TransactionYearView(UserMixin, TransactionACMixin, YearArchiveView):
h_data = context_data.get("transactions")
if not (context_data.get("account") or context_data.get("category")):
h_data = h_data.exclude(category__budget=False)
context_data["history"] = history(h_data)
return context_data | {"history": history(h_data)}
return context_data