Code cleanup
Use mixins for listviews
This commit is contained in:
parent
94671b9ac4
commit
1536e7f674
1 changed files with 18 additions and 10 deletions
|
@ -241,15 +241,7 @@ class AccountMixin:
|
|||
}
|
||||
|
||||
|
||||
class AccountTListView(AccountMixin, TransactionListView):
|
||||
pass
|
||||
|
||||
|
||||
class AccountSListView(AccountMixin, SnapshotListView):
|
||||
pass
|
||||
|
||||
|
||||
class SnapshotTListView(TransactionListView):
|
||||
class SnapshotMixin:
|
||||
def get_queryset(self):
|
||||
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):
|
||||
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):
|
||||
def post(self, *args, **kwargs):
|
||||
return redirect("search", search=self.request.POST.get("search"))
|
||||
|
|
Loading…
Reference in a new issue