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 {
|
.accounts {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-row-gap: 0.5rem;
|
grid-row-gap: 0.5rem;
|
||||||
|
grid-auto-rows: min-content;
|
||||||
|
|
||||||
dl {
|
dl {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
|
@ -30,18 +30,22 @@
|
||||||
</div>
|
</div>
|
||||||
<a href="{% url "new_account" %}">{% translate "Create account" %}</a>
|
<a href="{% url "new_account" %}">{% translate "Create account" %}</a>
|
||||||
</section>
|
</section>
|
||||||
<section class="categories">
|
<section class="statements">
|
||||||
<h2>{% translate "Categories" %}</h2>
|
<h2>{% translate "Statements" %}</h2>
|
||||||
{% spaceless %}
|
{% include "statement/statement_table.html" %}
|
||||||
<p>
|
|
||||||
{% for cat in categories %}
|
|
||||||
<a class="big-link" href="{{ cat.get_absolute_url }}">{{ cat.icon|remix }}{{ cat }}</a>
|
|
||||||
{% endfor %}
|
|
||||||
<a class="big-link add" href="{% url "new_category" %}">{{ "add"|remix }}{% translate "Create category" %}</a>
|
|
||||||
</p>
|
|
||||||
{% endspaceless %}
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
<section class="categories">
|
||||||
|
<h2>{% translate "Categories" %}</h2>
|
||||||
|
{% spaceless %}
|
||||||
|
<p>
|
||||||
|
{% for cat in categories %}
|
||||||
|
<a class="big-link" href="{{ cat.get_absolute_url }}">{{ cat.icon|remix }}{{ cat }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
<a class="big-link add" href="{% url "new_category" %}">{{ "add"|remix }}{% translate "Create category" %}</a>
|
||||||
|
</p>
|
||||||
|
{% endspaceless %}
|
||||||
|
</section>
|
||||||
{% if history %}
|
{% if history %}
|
||||||
<section>
|
<section>
|
||||||
<h2>{% translate "History" %}</h2>
|
<h2>{% translate "History" %}</h2>
|
||||||
|
|
|
@ -25,20 +25,23 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
_max = 8
|
_max = 8
|
||||||
_transactions = Transaction.objects.filter(user=self.request.user)
|
_transactions = Transaction.objects.filter(user=self.request.user)
|
||||||
_statements = Statement.objects.filter(user=self.request.user)
|
|
||||||
_accounts = Account.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 = {
|
res = {
|
||||||
"accounts": _accounts,
|
"accounts": _accounts,
|
||||||
"transactions": _transactions[:_max],
|
|
||||||
"categories": Category.objects.filter(user=self.request.user),
|
"categories": Category.objects.filter(user=self.request.user),
|
||||||
"statements": _statements[:_max],
|
"statements": _statements,
|
||||||
"history": history(_transactions.exclude(category__budget=False)),
|
"history": history(_transactions.exclude(category__budget=False)),
|
||||||
}
|
}
|
||||||
if _transactions.count() > _max:
|
if _transactions.count() > _max:
|
||||||
res["transactions_url"] = reverse_lazy("transactions")
|
res["transactions_url"] = reverse_lazy("transactions")
|
||||||
if _statements.count() > _max:
|
res["statements_url"] = reverse_lazy("statements")
|
||||||
res["statements_url"] = reverse_lazy("statements")
|
|
||||||
|
|
||||||
return super().get_context_data(**kwargs) | res
|
return super().get_context_data(**kwargs) | res
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue