Update snapshot page

This commit is contained in:
Edgar P. Burkhart 2023-04-18 14:35:15 +02:00
parent a14f73779b
commit ab3f7f4e40
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -280,15 +280,10 @@ class SnapshotUpdateView(NummiUpdateView):
form_class = SnapshotForm
def get_context_data(self, **kwargs):
_max = 8
data = super().get_context_data(**kwargs)
snapshot = data["form"].instance
_transactions = snapshot.transaction_set.all()
if _transactions.count() > _max:
data["transactions_url"] = reverse_lazy(
"snapshot_transactions", args=(snapshot.pk,)
)
if _transactions:
_categories = (
_transactions.values("category", "category__name", "category__icon")
@ -310,10 +305,11 @@ class SnapshotUpdateView(NummiUpdateView):
}
return data | {
"account": snapshot.account,
"new_transaction_url": reverse_lazy(
"transaction", kwargs={"snapshot": snapshot.pk}
),
"transactions": _transactions[:_max],
"transactions": _transactions,
}