Compare commits

..

2 commits

Author SHA1 Message Date
6b54cc7546
Hide tables on account form when empty 2022-12-31 11:39:39 +01:00
1536e7f674
Code cleanup
Use mixins for listviews
2022-12-31 11:38:39 +01:00
2 changed files with 26 additions and 14 deletions

View file

@ -19,8 +19,12 @@
{% csrf_token %}
{{ form }}
</form>
<h2>{% translate "Statements" %}</h2>
{% include "main/table/snapshot.html" %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
{% if snapshots %}
<h2>{% translate "Statements" %}</h2>
{% include "main/table/snapshot.html" %}
{% endif %}
{% if transactions %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
{% endif %}
{% endblock %}

View file

@ -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"))