Add last statements to home page
This commit is contained in:
parent
c754e869fc
commit
412cf94f93
3 changed files with 23 additions and 15 deletions
|
@ -336,6 +336,7 @@ ul.messages {
|
|||
.accounts {
|
||||
display: grid;
|
||||
grid-row-gap: 0.5rem;
|
||||
grid-auto-rows: min-content;
|
||||
|
||||
dl {
|
||||
margin: 0;
|
||||
|
|
|
@ -30,6 +30,11 @@
|
|||
</div>
|
||||
<a href="{% url "new_account" %}">{% translate "Create account" %}</a>
|
||||
</section>
|
||||
<section class="statements">
|
||||
<h2>{% translate "Statements" %}</h2>
|
||||
{% include "statement/statement_table.html" %}
|
||||
</section>
|
||||
</div>
|
||||
<section class="categories">
|
||||
<h2>{% translate "Categories" %}</h2>
|
||||
{% spaceless %}
|
||||
|
@ -41,7 +46,6 @@
|
|||
</p>
|
||||
{% endspaceless %}
|
||||
</section>
|
||||
</div>
|
||||
{% if history %}
|
||||
<section>
|
||||
<h2>{% translate "History" %}</h2>
|
||||
|
|
|
@ -25,19 +25,22 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
|||
def get_context_data(self, **kwargs):
|
||||
_max = 8
|
||||
_transactions = Transaction.objects.filter(user=self.request.user)
|
||||
_statements = Statement.objects.filter(user=self.request.user)
|
||||
_accounts = Account.objects.filter(user=self.request.user)
|
||||
_statements = (
|
||||
Statement.objects.filter(user=self.request.user)
|
||||
.exclude(account__archived=True)
|
||||
.order_by("account__id", "-date")
|
||||
.distinct("account__id")
|
||||
)
|
||||
|
||||
res = {
|
||||
"accounts": _accounts,
|
||||
"transactions": _transactions[:_max],
|
||||
"categories": Category.objects.filter(user=self.request.user),
|
||||
"statements": _statements[:_max],
|
||||
"statements": _statements,
|
||||
"history": history(_transactions.exclude(category__budget=False)),
|
||||
}
|
||||
if _transactions.count() > _max:
|
||||
res["transactions_url"] = reverse_lazy("transactions")
|
||||
if _statements.count() > _max:
|
||||
res["statements_url"] = reverse_lazy("statements")
|
||||
|
||||
return super().get_context_data(**kwargs) | res
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue