Only show all transactions line when number is strictly higher than showed
This commit is contained in:
parent
7c5e804aba
commit
2a898c706e
1 changed files with 10 additions and 7 deletions
|
@ -26,19 +26,22 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
|||
template_name = "main/index.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
_max = 10
|
||||
res = super().get_context_data(**kwargs) | {
|
||||
_max = 8
|
||||
_transactions = Transaction.objects.filter(user=self.request.user)
|
||||
_snapshots = Snapshot.objects.filter(user=self.request.user)
|
||||
|
||||
res = {
|
||||
"accounts": Account.objects.filter(user=self.request.user),
|
||||
"transactions": Transaction.objects.filter(user=self.request.user)[:10],
|
||||
"transactions": _transactions[:_max],
|
||||
"categories": Category.objects.filter(user=self.request.user),
|
||||
"snapshots": Snapshot.objects.filter(user=self.request.user)[:10],
|
||||
"snapshots": _snapshots[:_max],
|
||||
}
|
||||
if res["transactions"].count() == 10:
|
||||
if _transactions.count() > _max:
|
||||
res["transactions_url"] = reverse_lazy("transactions")
|
||||
if res["snapshots"].count() == 10:
|
||||
if _snapshots.count() > _max:
|
||||
res["snapshots_url"] = reverse_lazy("snapshots")
|
||||
|
||||
return res
|
||||
return super().get_context_data(**kwargs) | res
|
||||
|
||||
|
||||
class UserMixin(LoginRequiredMixin):
|
||||
|
|
Loading…
Reference in a new issue