Move transaction link

Close 
Progress 
This commit is contained in:
Edgar P. Burkhart 2025-01-04 14:17:48 +01:00
parent 805c7d3dc0
commit e1f29f90c6
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
9 changed files with 53 additions and 23 deletions
nummi
category/templates/category
main
statement/templates/statement
transaction/templates/transaction

View file

@ -16,6 +16,9 @@
<section>
<h3>{% translate "Transactions" %}</h3>
{% url "category_transactions" category.id as t_url %}
<p>
<a class="big-link" href="{{ t_url }}">{{ "list-check"|remixnl }}{% translate "View all transactions" %}</a>
</p>
{% transaction_table category.transaction_set.all n_max=8 transactions_url=t_url %}
</section>
<section>

View file

@ -522,7 +522,8 @@ ul.statements {
}
}
.category {
.category,
.big-link {
padding: 0 var(--gap);
border: var(--gray) 1px solid;
margin-right: 0.5rem;

View file

@ -45,9 +45,7 @@ table {
font-weight: 300;
}
}
tfoot tr:not(.new) {
background: var(--bg-01);
}
.l {
text-align: left;
}

View file

@ -1,11 +1,6 @@
{% load i18n transaction_extras %}
{% load i18n main_extras transaction_extras %}
{% if page_obj %}
<p class="pagination">
{% for page in paginator.page_range %}
<a href="?page={{ page }}"
{% if page == page_obj.number %}class="cur"{% endif %}>{{ page }}</a>
{% endfor %}
</p>
<p class="pagination">{% pagination_links page_obj %}</p>
{% endif %}
{% if month %}
<p class="pagination">{% year_url month %}</p>

View file

@ -0,0 +1,13 @@
{% load i18n main_extras %}
{% if first.show %}
<a href="?page=1" class="first">1</a>
{% if first.dots %}<span></span>{% endif %}
{% endif %}
{% for page in pages %}
<a href="?page={{ page.number }}"
{% if page.current %}class="cur"{% endif %}>{{ page.number }}</a>
{% endfor %}
{% if last.show %}
{% if last.dots %}<span></span>{% endif %}
<a href="?page={{ last.number }}" class="last">{{ last.number }}</a>
{% endif %}

View file

@ -89,3 +89,24 @@ def balance(accounts):
return sum(
statement.value for acc in accounts if (statement := acc.statement_set.first())
)
@register.inclusion_tag("main/pagination_links.html")
def pagination_links(page_obj):
_n = 3
return {
"pages": [
{"number": p, "current": p == page_obj.number}
for p in page_obj.paginator.page_range
if abs(p - page_obj.number) < _n
],
"first": {
"show": page_obj.number > _n,
"dots": page_obj.number > _n + 1,
},
"last": {
"show": page_obj.number <= page_obj.paginator.num_pages - _n,
"dots": page_obj.number < page_obj.paginator.num_pages - _n,
"number": page_obj.paginator.num_pages,
},
}

View file

@ -56,8 +56,12 @@
<section>
<h3>{% translate "Transactions" %}</h3>
{% url "statement_transactions" statement.id as t_url %}
{% url "new_transaction" statement=statement.id as nt_url %}
{% transaction_table statement.transaction_set.all n_max=8 transactions_url=t_url new_transaction_url=nt_url %}
<p>
<a class="big-link"
href="{% url "new_transaction" statement=statement.id %}">{{ "add-circle"|remix }}{% translate "Add transaction" %}</a>
<a class="big-link" href="{{ t_url }}">{{ "list-check"|remixnl }}{% translate "View all transactions" %}</a>
</p>
{% transaction_table statement.transaction_set.all n_max=8 transactions_url=t_url %}
</section>
<section>
<h3>{% translate "Categories" %}</h3>

View file

@ -1,5 +1,5 @@
{% extends "main/list.html" %}
{% load i18n transaction_extras %}
{% load i18n main_extras transaction_extras %}
{% block name %}
{% translate "Transactions" %}
{% endblock name %}
@ -7,6 +7,8 @@
{% translate "Transactions" %}
{% endblock h2 %}
{% block table %}
{% url "new_transaction" as nt_url %}
{% transaction_table transactions new_transaction_url=nt_url %}
<p>
<a class="big-link" href="{% url "new_transaction" %}">{{ "add-circle"|remix }}{% translate "Add transaction" %}</a>
</p>
{% transaction_table transactions %}
{% endblock table %}

View file

@ -13,13 +13,6 @@
{% if not hide_account %}<col class="desc">{% endif %}
</colgroup>
<thead>
{% if new_transaction_url %}
<tr class="new">
<td colspan="{{ ncol }}">
<a href="{{ new_transaction_url }}">{% translate "Create transaction" %}</a>
</td>
</tr>
{% endif %}
<tr>
<th>{{ "attachment"|remix }}</th>
<th>{% translate "Date" %}</th>