Update all transaction lists
This commit is contained in:
parent
2a898c706e
commit
7f4b6a0415
5 changed files with 43 additions and 6 deletions
|
@ -19,4 +19,5 @@
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{{ form }}
|
{{ form }}
|
||||||
</form>
|
</form>
|
||||||
|
{% include "main/table/transaction.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
<img src="{% url "plot-category" form.instance.id %}"
|
<img src="{% url "plot-category" form.instance.id %}"
|
||||||
alt="Graph representing value over time"/>
|
alt="Graph representing value over time"/>
|
||||||
<h2>{% translate "Transactions" %}</h2>
|
<h2>{% translate "Transactions" %}</h2>
|
||||||
{% with transactions=form.instance.transactions %}
|
{% include "main/table/transaction.html" %}
|
||||||
{% include "main/table/transaction.html" %}
|
|
||||||
{% endwith %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -73,9 +73,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if snapshot.transaction_set.all %}
|
{% if snapshot.transaction_set.all %}
|
||||||
<h2>{% translate "Transactions" %} ({{ snapshot.sum|pmvalue }} / {{ snapshot.diff|pmvalue }})</h2>
|
<h2>{% translate "Transactions" %} ({{ snapshot.sum|pmvalue }} / {{ snapshot.diff|pmvalue }})</h2>
|
||||||
{% with transactions=snapshot.transaction_set.all %}
|
{% include "main/table/transaction.html" %}
|
||||||
{% include "main/table/transaction.html" %}
|
|
||||||
{% endwith %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -35,6 +35,11 @@ urlpatterns = [
|
||||||
name="invoice",
|
name="invoice",
|
||||||
),
|
),
|
||||||
path("category/<pk>", views.CategoryUpdateView.as_view(), name="category"),
|
path("category/<pk>", views.CategoryUpdateView.as_view(), name="category"),
|
||||||
|
path(
|
||||||
|
"category/<pk>/transactions",
|
||||||
|
views.CategoryTListView.as_view(),
|
||||||
|
name="category_transactions",
|
||||||
|
),
|
||||||
path("snapshot/<pk>", views.SnapshotUpdateView.as_view(), name="snapshot"),
|
path("snapshot/<pk>", views.SnapshotUpdateView.as_view(), name="snapshot"),
|
||||||
path(
|
path(
|
||||||
"snapshot/<pk>/transactions",
|
"snapshot/<pk>/transactions",
|
||||||
|
|
|
@ -120,6 +120,16 @@ class AccountUpdateView(NummiUpdateView):
|
||||||
model = Account
|
model = Account
|
||||||
form_class = AccountForm
|
form_class = AccountForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
data = super().get_context_data(**kwargs)
|
||||||
|
account = data["form"].instance
|
||||||
|
return data | {
|
||||||
|
"transactions": account.transaction_set.all()[:8],
|
||||||
|
"transactions_url": reverse_lazy(
|
||||||
|
"account_transactions", args=(account.pk,)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class TransactionUpdateView(NummiUpdateView):
|
class TransactionUpdateView(NummiUpdateView):
|
||||||
model = Transaction
|
model = Transaction
|
||||||
|
@ -149,11 +159,31 @@ class CategoryUpdateView(NummiUpdateView):
|
||||||
model = Category
|
model = Category
|
||||||
form_class = CategoryForm
|
form_class = CategoryForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
data = super().get_context_data(**kwargs)
|
||||||
|
category = data["form"].instance
|
||||||
|
return data | {
|
||||||
|
"transactions": category.transaction_set.all()[:8],
|
||||||
|
"transactions_url": reverse_lazy(
|
||||||
|
"category_transactions", args=(category.pk,)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class SnapshotUpdateView(NummiUpdateView):
|
class SnapshotUpdateView(NummiUpdateView):
|
||||||
model = Snapshot
|
model = Snapshot
|
||||||
form_class = SnapshotForm
|
form_class = SnapshotForm
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
data = super().get_context_data(**kwargs)
|
||||||
|
snapshot = data["form"].instance
|
||||||
|
return data | {
|
||||||
|
"transactions": snapshot.transaction_set.all()[:8],
|
||||||
|
"transactions_url": reverse_lazy(
|
||||||
|
"snapshot_transactions", args=(snapshot.pk,)
|
||||||
|
),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AccountDeleteView(NummiDeleteView):
|
class AccountDeleteView(NummiDeleteView):
|
||||||
model = Account
|
model = Account
|
||||||
|
@ -217,6 +247,11 @@ class SnapshotTListView(TransactionListView):
|
||||||
return super().get_queryset().filter(snapshot=self.kwargs.get("pk"))
|
return super().get_queryset().filter(snapshot=self.kwargs.get("pk"))
|
||||||
|
|
||||||
|
|
||||||
|
class CategoryTListView(TransactionListView):
|
||||||
|
def get_queryset(self):
|
||||||
|
return super().get_queryset().filter(category=self.kwargs.get("pk"))
|
||||||
|
|
||||||
|
|
||||||
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"))
|
||||||
|
|
Loading…
Reference in a new issue