Code cleanup

Use mixins for listviews
This commit is contained in:
Edgar P. Burkhart 2022-12-31 11:38:39 +01:00
parent 94671b9ac4
commit 1536e7f674
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227

View file

@ -241,15 +241,7 @@ class AccountMixin:
} }
class AccountTListView(AccountMixin, TransactionListView): class SnapshotMixin:
pass
class AccountSListView(AccountMixin, SnapshotListView):
pass
class SnapshotTListView(TransactionListView):
def get_queryset(self): def get_queryset(self):
return super().get_queryset().filter(snapshot=self.kwargs.get("pk")) return super().get_queryset().filter(snapshot=self.kwargs.get("pk"))
@ -259,7 +251,7 @@ class SnapshotTListView(TransactionListView):
} }
class CategoryTListView(TransactionListView): class CategoryMixin:
def get_queryset(self): def get_queryset(self):
return super().get_queryset().filter(category=self.kwargs.get("pk")) return super().get_queryset().filter(category=self.kwargs.get("pk"))
@ -269,6 +261,22 @@ class CategoryTListView(TransactionListView):
} }
class AccountTListView(AccountMixin, TransactionListView):
pass
class AccountSListView(AccountMixin, SnapshotListView):
pass
class SnapshotTListView(SnapshotMixin, TransactionListView):
pass
class CategoryTListView(CategoryMixin, TransactionListView):
pass
class SearchView(TransactionListView): class SearchView(TransactionListView):
def post(self, *args, **kwargs): def post(self, *args, **kwargs):
return redirect("search", search=self.request.POST.get("search")) return redirect("search", search=self.request.POST.get("search"))