diff --git a/nummi/main/static/main/css/table.css b/nummi/main/static/main/css/table.css index 358ac2b..5902d8d 100644 --- a/nummi/main/static/main/css/table.css +++ b/nummi/main/static/main/css/table.css @@ -49,3 +49,7 @@ overflow: hidden; text-overflow: ellipsis; } +.table > div.full-line > * { + grid-column: 1 / -1; + text-align: center; +} diff --git a/nummi/main/templates/main/category_form.html b/nummi/main/templates/main/category_form.html index b6422fd..01e17fe 100644 --- a/nummi/main/templates/main/category_form.html +++ b/nummi/main/templates/main/category_form.html @@ -23,6 +23,8 @@ Graph representing value over time

{% translate "Transactions" %}

- {% transaction_table form.instance.transactions %} + {% with transactions=form.instance.transactions %} + {% include "main/table/transaction.html" %} + {% endwith %} {% endif %} {% endblock %} diff --git a/nummi/main/templates/main/index.html b/nummi/main/templates/main/index.html index e9e321b..503d0fe 100644 --- a/nummi/main/templates/main/index.html +++ b/nummi/main/templates/main/index.html @@ -23,13 +23,8 @@ {% endspaceless %} {% endif %} {% if transactions %} -

- {% translate "Transactions" %} - - - -

- {% transaction_table transactions %} +

{% translate "Transactions" %}

+ {% include "main/table/transaction.html" %} {% endif %} {% if categories %}

{% translate "Categories" %}

@@ -43,6 +38,6 @@ {% endif %} {% if snapshots %}

{% translate "Snapshots" %}

- {% snapshot_table snapshots %} + {% include "main/table/snapshot.html" %} {% endif %} {% endblock %} diff --git a/nummi/main/templates/main/snapshots.html b/nummi/main/templates/main/list/snapshot.html similarity index 96% rename from nummi/main/templates/main/snapshots.html rename to nummi/main/templates/main/list/snapshot.html index bf0c461..5c8eaf7 100644 --- a/nummi/main/templates/main/snapshots.html +++ b/nummi/main/templates/main/list/snapshot.html @@ -14,7 +14,7 @@ {% block body %}

{% translate "Statements" %}

{% if snapshots %} - {% snapshot_table snapshots %} + {% include "main/table/snapshot.html" %} {% if page_obj %} diff --git a/nummi/main/templates/main/tag/snapshot_table.html b/nummi/main/templates/main/tag/snapshot_table.html deleted file mode 100644 index a4ea80f..0000000 --- a/nummi/main/templates/main/tag/snapshot_table.html +++ /dev/null @@ -1,43 +0,0 @@ -{% load main_extras %} -{% load i18n %} -
-
- - {% translate "Date" %} - - {% translate "Value" %} - {% translate "Difference" %} - {% translate "Transactions" %} - {% translate "Valid" %} -
- {% for snap in snapshots %} -
- - {% if snap.file %} - - - - {% endif %} - - - {{ snap.date|date:"Y-m-d" }} - - - {{ snap.value|value }} - {{ snap.diff|pmvalue }} - {% with sum=snap.sum %} - {{ sum|pmvalue }} - - {% if sum == snap.diff %} - - {% else %} - - {% endif %} - - {% endwith %} -
- {% endfor %} -
diff --git a/nummi/main/templatetags/main_extras.py b/nummi/main/templatetags/main_extras.py index 6205a59..3115d01 100644 --- a/nummi/main/templatetags/main_extras.py +++ b/nummi/main/templatetags/main_extras.py @@ -28,16 +28,6 @@ def pmvalue(val): return value(val, True) -@register.inclusion_tag("main/tag/transaction_table.html") -def transaction_table(transactions): - return {"transactions": transactions} - - -@register.inclusion_tag("main/tag/snapshot_table.html") -def snapshot_table(snapshots): - return {"snapshots": snapshots} - - @register.inclusion_tag("main/tag/form_buttons.html") def form_buttons(instance): return { diff --git a/nummi/main/views.py b/nummi/main/views.py index 9738afd..c9cdbdd 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -26,12 +26,19 @@ class IndexView(LoginRequiredMixin, TemplateView): template_name = "main/index.html" def get_context_data(self, **kwargs): - return super().get_context_data(**kwargs) | { + _max = 10 + res = super().get_context_data(**kwargs) | { "accounts": Account.objects.filter(user=self.request.user), "transactions": Transaction.objects.filter(user=self.request.user)[:10], "categories": Category.objects.filter(user=self.request.user), "snapshots": Snapshot.objects.filter(user=self.request.user)[:10], } + if res["transactions"].count() == 10: + res["transactions_url"] = reverse_lazy("transactions") + if res["snapshots"].count() == 10: + res["snapshots_url"] = (reverse_lazy("snapshots"),) + + return res class UserMixin(LoginRequiredMixin): @@ -179,13 +186,13 @@ class NummiListView(UserMixin, ListView): class TransactionListView(NummiListView): model = Transaction - template_name = "main/transactions.html" + template_name = "main/list/transaction.html" context_object_name = "transactions" class SnapshotListView(NummiListView): model = Snapshot - template_name = "main/snapshots.html" + template_name = "main/list/snapshot.html" context_object_name = "snapshots"