Add transaction list views for snapshots and accounts
This commit is contained in:
parent
4e6dd25c99
commit
8f14c20d55
2 changed files with 23 additions and 8 deletions
|
@ -17,6 +17,11 @@ urlpatterns = [
|
||||||
path("category", views.CategoryCreateView.as_view(), name="category"),
|
path("category", views.CategoryCreateView.as_view(), name="category"),
|
||||||
path("snapshot", views.SnapshotCreateView.as_view(), name="snapshot"),
|
path("snapshot", views.SnapshotCreateView.as_view(), name="snapshot"),
|
||||||
path("account/<pk>", views.AccountUpdateView.as_view(), name="account"),
|
path("account/<pk>", views.AccountUpdateView.as_view(), name="account"),
|
||||||
|
path(
|
||||||
|
"account/<pk>/transactions",
|
||||||
|
views.AccountTListView.as_view(),
|
||||||
|
name="account_transactions",
|
||||||
|
),
|
||||||
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
||||||
path(
|
path(
|
||||||
"transaction/<transaction_pk>/invoice/<pk>",
|
"transaction/<transaction_pk>/invoice/<pk>",
|
||||||
|
@ -25,6 +30,11 @@ urlpatterns = [
|
||||||
),
|
),
|
||||||
path("category/<pk>", views.CategoryUpdateView.as_view(), name="category"),
|
path("category/<pk>", views.CategoryUpdateView.as_view(), name="category"),
|
||||||
path("snapshot/<pk>", views.SnapshotUpdateView.as_view(), name="snapshot"),
|
path("snapshot/<pk>", views.SnapshotUpdateView.as_view(), name="snapshot"),
|
||||||
|
path(
|
||||||
|
"snapshot/<pk>/transactions",
|
||||||
|
views.SnapshotTListView.as_view(),
|
||||||
|
name="snapshot_transactions",
|
||||||
|
),
|
||||||
path(
|
path(
|
||||||
"account/<pk>/delete",
|
"account/<pk>/delete",
|
||||||
views.AccountDeleteView.as_view(),
|
views.AccountDeleteView.as_view(),
|
||||||
|
|
|
@ -71,13 +71,6 @@ class LogoutView(auth_views.LogoutView):
|
||||||
next_page = "login"
|
next_page = "login"
|
||||||
|
|
||||||
|
|
||||||
class TransactionListView(UserMixin, ListView):
|
|
||||||
paginate_by = 24
|
|
||||||
model = Transaction
|
|
||||||
template_name = "main/transactions.html"
|
|
||||||
context_object_name = "transactions"
|
|
||||||
|
|
||||||
|
|
||||||
class AccountCreateView(NummiCreateView):
|
class AccountCreateView(NummiCreateView):
|
||||||
model = Account
|
model = Account
|
||||||
form_class = AccountForm
|
form_class = AccountForm
|
||||||
|
@ -180,12 +173,24 @@ class SnapshotDeleteView(NummiDeleteView):
|
||||||
model = Snapshot
|
model = Snapshot
|
||||||
|
|
||||||
|
|
||||||
class SearchView(UserMixin, UserFormMixin, ListView):
|
class TransactionListView(UserMixin, ListView):
|
||||||
paginate_by = 24
|
paginate_by = 24
|
||||||
model = Transaction
|
model = Transaction
|
||||||
template_name = "main/transactions.html"
|
template_name = "main/transactions.html"
|
||||||
context_object_name = "transactions"
|
context_object_name = "transactions"
|
||||||
|
|
||||||
|
|
||||||
|
class AccountTListView(TransactionListView):
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().filter(account=self.kwargs.get("pk"))
|
||||||
|
|
||||||
|
|
||||||
|
class SnapshotTListView(TransactionListView):
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().filter(snapshot=self.kwargs.get("pk"))
|
||||||
|
|
||||||
|
|
||||||
|
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"))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue