Compare commits
No commits in common. "57279b1cda6abcc6ba7a3bfc64b2993f721dd596" and "1137cfc1ccaa696f18dbbcc7f9f9dae3c7880e72" have entirely different histories.
57279b1cda
...
1137cfc1cc
2 changed files with 27 additions and 12 deletions
|
@ -84,8 +84,6 @@ table.full-width col.bar {
|
|||
}
|
||||
|
||||
.calendar {
|
||||
overflow-x: auto;
|
||||
|
||||
margin-top: var(--gap);
|
||||
font-feature-settings: var(--num);
|
||||
|
||||
|
|
|
@ -110,8 +110,11 @@ class TransactionListView(NummiListView):
|
|||
context_object_name = "transactions"
|
||||
|
||||
|
||||
class TransactionACMixin:
|
||||
class TransactionMonthView(UserMixin, MonthArchiveView):
|
||||
model = Transaction
|
||||
date_field = "date"
|
||||
context_object_name = "transactions"
|
||||
month_format = "%m"
|
||||
|
||||
def get_queryset(self):
|
||||
if "account" in self.kwargs:
|
||||
|
@ -138,23 +141,37 @@ class TransactionACMixin:
|
|||
return context_data
|
||||
|
||||
|
||||
class TransactionMonthView(UserMixin, TransactionACMixin, MonthArchiveView):
|
||||
model = Transaction
|
||||
date_field = "date"
|
||||
context_object_name = "transactions"
|
||||
month_format = "%m"
|
||||
|
||||
|
||||
class TransactionYearView(UserMixin, TransactionACMixin, YearArchiveView):
|
||||
class TransactionYearView(UserMixin, YearArchiveView):
|
||||
model = Transaction
|
||||
date_field = "date"
|
||||
context_object_name = "transactions"
|
||||
make_object_list = True
|
||||
|
||||
def get_queryset(self):
|
||||
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 "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):
|
||||
context_data = super().get_context_data(**kwargs)
|
||||
return context_data | {
|
||||
context_data |= {
|
||||
"history": history(
|
||||
context_data["transactions"].exclude(category__budget=False)
|
||||
),
|
||||
}
|
||||
if "category" in self.kwargs:
|
||||
return context_data | {"category": self.category}
|
||||
if "account" in self.kwargs:
|
||||
return context_data | {"account": self.account}
|
||||
return context_data
|
||||
|
|
Loading…
Reference in a new issue