From 0e1c1be1899c95685fc166e60e1ce05e0efadeab Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Fri, 21 Apr 2023 18:58:46 +0200 Subject: [PATCH] Fix monthly view for category and account --- nummi/main/views.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nummi/main/views.py b/nummi/main/views.py index 8a370ad..b40c629 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -444,24 +444,24 @@ class TransactionMonthView(UserMixin, MonthArchiveView): category = None def get_queryset(self): - if self.account: + if "account" in self.kwargs: + self.account = get_object_or_404( + Account.objects.filter(user=self.request.user), + pk=self.kwargs["account"], + ) return super().get_queryset().filter(account=self.account) - if self.category: + if "category" in self.kwargs: + self.category = get_object_or_404( + Category.objects.filter(user=self.request.user), + pk=self.kwargs["category"], + ) return super().get_queryset().filter(category=self.category) return super().get_queryset() def get_context_data(self, **kwargs): if "account" in self.kwargs: - self.account = get_object_or_404( - Account.objects.filter(user=self.request.user), - pk=self.kwargs["account"], - ) return super().get_context_data(**kwargs) | {"account": self.account} if "category" in self.kwargs: - self.category = get_object_or_404( - Category.objects.filter(user=self.request.user), - pk=self.kwargs["category"], - ) return super().get_context_data(**kwargs) | {"category": self.category} return super().get_context_data(**kwargs)