Use templatetags for statement_table

This commit is contained in:
Edgar P. Burkhart 2025-01-02 14:19:06 +01:00
parent 090f1a3a5c
commit 786d7c2130
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
5 changed files with 23 additions and 13 deletions

View file

@ -1,12 +1,14 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% load main_extras %} {% load main_extras statement_extras %}
{% load i18n %} {% load i18n %}
{% block title %}{{ object }} {{ block.super }}{% endblock %} {% block title %}
{{ object }} {{ block.super }}
{% endblock title %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
{% css "main/css/table.css" %} {% css "main/css/table.css" %}
{% css "main/css/plot.css" %} {% css "main/css/plot.css" %}
{% endblock %} {% endblock link %}
{% block body %} {% block body %}
<h2>{{ object.icon|remix }}{{ object }}</h2> <h2>{{ object.icon|remix }}{{ object }}</h2>
<p> <p>
@ -14,7 +16,7 @@
</p> </p>
<section> <section>
<h3>{% translate "Statements" %}</h3> <h3>{% translate "Statements" %}</h3>
{% include "statement/statement_table.html" %} {% statement_table statements statements_url=statements_url new_statement_url=new_statement_url %}
</section> </section>
{% if history %} {% if history %}
<section> <section>
@ -22,4 +24,4 @@
{% include "history/plot.html" %} {% include "history/plot.html" %}
</section> </section>
{% endif %} {% endif %}
{% endblock %} {% endblock body %}

View file

@ -9,6 +9,7 @@ from main.views import (
NummiUpdateView, NummiUpdateView,
) )
from statement.views import StatementListView from statement.views import StatementListView
from transaction.models import Transaction
from transaction.views import TransactionListView from transaction.views import TransactionListView
from .forms import AccountForm from .forms import AccountForm
@ -51,7 +52,7 @@ class AccountDetailView(NummiDetailView):
"new_statement", kwargs={"account": account.pk} "new_statement", kwargs={"account": account.pk}
), ),
"statements": _statements[:_max], "statements": _statements[:_max],
"history": history(account.transaction_set), "history": history(Transaction.objects.filter(statement__account=account)),
} }

View file

@ -1,6 +1,6 @@
{% extends "main/base.html" %} {% extends "main/base.html" %}
{% load static %} {% load static %}
{% load main_extras account_extras %} {% load main_extras account_extras statement_extras %}
{% load i18n %} {% load i18n %}
{% block link %} {% block link %}
{{ block.super }} {{ block.super }}
@ -16,7 +16,7 @@
</section> </section>
<section> <section>
<h2>{% translate "Statements" %}</h2> <h2>{% translate "Statements" %}</h2>
{% include "statement/statement_table.html" %} {% statement_table statements statements_url=statements_url %}
</section> </section>
</div> </div>
<section> <section>

View file

@ -1,12 +1,12 @@
{% extends "main/list.html" %} {% extends "main/list.html" %}
{% load i18n %} {% load i18n statement_extras %}
{% block name %} {% block name %}
{% translate "Statements" %} {% translate "Statements" %}
{% endblock %} {% endblock name %}
{% block h2 %} {% block h2 %}
{% translate "Statements" %} {% translate "Statements" %}
{% endblock %} {% endblock h2 %}
{% block table %} {% block table %}
{% url "new_statement" as new_statement_url %} {% url "new_statement" as new_statement_url %}
{% include "statement/statement_table.html" %} {% statement_table statements new_statement_url=new_statement_url %}
{% endblock %} {% endblock table %}

View file

@ -12,3 +12,10 @@ def check(s, diff):
return remix("check", "green") return remix("check", "green")
else: else:
return remix("close", "red") return remix("close", "red")
@register.inclusion_tag("statement/statement_table.html")
def statement_table(statements, **kwargs):
return kwargs | {
"statements": statements,
}