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