Use templatetag for statement_table
This commit is contained in:
parent
786d7c2130
commit
b1fddd0dd6
7 changed files with 20 additions and 37 deletions
|
@ -16,7 +16,9 @@
|
|||
</p>
|
||||
<section>
|
||||
<h3>{% translate "Statements" %}</h3>
|
||||
{% statement_table statements statements_url=statements_url new_statement_url=new_statement_url %}
|
||||
{% url "new_statement" account=account.pk as ns_url %}
|
||||
{% url "account_statements" account=account.pk as s_url %}
|
||||
{% statement_table account.statement_set.all statements_url=s_url new_statement_url=ns_url n_max=6 %}
|
||||
</section>
|
||||
{% if history %}
|
||||
<section>
|
||||
|
|
|
@ -15,11 +15,9 @@
|
|||
<dt>
|
||||
<a href="{% url "accounts" %}">{{ "gallery-view"|remixnl }}{% translate "All accounts" %}</a>
|
||||
</dt>
|
||||
{% if total %}
|
||||
<dd class="value">
|
||||
{{ total|value }}
|
||||
</dd>
|
||||
{% endif %}
|
||||
<dd class="value">
|
||||
{{ accounts|balance|value }}
|
||||
</dd>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="more account">
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse_lazy
|
||||
from history.utils import history
|
||||
from main.views import (
|
||||
NummiCreateView,
|
||||
|
@ -37,21 +36,10 @@ class AccountDetailView(NummiDetailView):
|
|||
pk_url_kwarg = "account"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
_max = 6
|
||||
data = super().get_context_data(**kwargs)
|
||||
account = data.get("object")
|
||||
|
||||
_statements = account.statement_set.all()
|
||||
if _statements.count() > _max:
|
||||
data["statements_url"] = reverse_lazy(
|
||||
"account_statements", args=(account.pk,)
|
||||
)
|
||||
|
||||
return data | {
|
||||
"new_statement_url": reverse_lazy(
|
||||
"new_statement", kwargs={"account": account.pk}
|
||||
),
|
||||
"statements": _statements[:_max],
|
||||
"history": history(Transaction.objects.filter(statement__account=account)),
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue