Fix monthly view for category and account

This commit is contained in:
Edgar P. Burkhart 2023-04-21 18:58:46 +02:00
parent 17e150032e
commit 0e1c1be189
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -444,24 +444,24 @@ class TransactionMonthView(UserMixin, MonthArchiveView):
category = None category = None
def get_queryset(self): 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) 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().filter(category=self.category)
return super().get_queryset() return super().get_queryset()
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
if "account" in 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} return super().get_context_data(**kwargs) | {"account": self.account}
if "category" in self.kwargs: 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) | {"category": self.category}
return super().get_context_data(**kwargs) return super().get_context_data(**kwargs)