Update templates with new snapshot and transaction tables
Add link on homepage to see all transactions and snapshots
This commit is contained in:
parent
057734afd3
commit
9c978723ef
11 changed files with 78 additions and 68 deletions
|
@ -49,3 +49,7 @@
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.table > div.full-line > * {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
<img src="{% url "plot-category" form.instance.id %}"
|
||||
alt="Graph representing value over time"/>
|
||||
<h2>{% translate "Transactions" %}</h2>
|
||||
{% transaction_table form.instance.transactions %}
|
||||
{% with transactions=form.instance.transactions %}
|
||||
{% include "main/table/transaction.html" %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -23,13 +23,8 @@
|
|||
{% endspaceless %}
|
||||
{% endif %}
|
||||
{% if transactions %}
|
||||
<h2>
|
||||
{% translate "Transactions" %}
|
||||
<a href="{% url "transactions" %}">
|
||||
<i class="fa fa-magnifying-glass-plus"></i>
|
||||
</a>
|
||||
</h2>
|
||||
{% transaction_table transactions %}
|
||||
<h2>{% translate "Transactions" %}</h2>
|
||||
{% include "main/table/transaction.html" %}
|
||||
{% endif %}
|
||||
{% if categories %}
|
||||
<h2>{% translate "Categories" %}</h2>
|
||||
|
@ -43,6 +38,6 @@
|
|||
{% endif %}
|
||||
{% if snapshots %}
|
||||
<h2>{% translate "Snapshots" %}</h2>
|
||||
{% snapshot_table snapshots %}
|
||||
{% include "main/table/snapshot.html" %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
{% block body %}
|
||||
<h1>{% translate "Statements" %}</h1>
|
||||
{% if snapshots %}
|
||||
{% snapshot_table snapshots %}
|
||||
{% include "main/table/snapshot.html" %}
|
||||
{% if page_obj %}
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
|
@ -14,7 +14,7 @@
|
|||
{% block body %}
|
||||
<h1>{% translate "Transactions" %}</h1>
|
||||
{% if transactions %}
|
||||
{% transaction_table transactions %}
|
||||
{% include "main/table/transaction.html" %}
|
||||
{% if page_obj %}
|
||||
<div class="pagination">
|
||||
<span class="step-links">
|
|
@ -73,7 +73,9 @@
|
|||
{% endif %}
|
||||
{% if snapshot.transaction_set.all %}
|
||||
<h2>{% translate "Transactions" %} ({{ snapshot.sum|pmvalue }} / {{ snapshot.diff|pmvalue }})</h2>
|
||||
{% transaction_table snapshot.transaction_set.all %}
|
||||
{% with transactions=snapshot.transaction_set.all %}
|
||||
{% include "main/table/transaction.html" %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% endblock %}
|
||||
|
|
48
nummi/main/templates/main/table/snapshot.html
Normal file
48
nummi/main/templates/main/table/snapshot.html
Normal file
|
@ -0,0 +1,48 @@
|
|||
{% load main_extras %}
|
||||
{% load i18n %}
|
||||
<div id="snapshots" class="table col1-6">
|
||||
<div class="header">
|
||||
<strong class="attach center"><i class="fa fa-paperclip"></i></strong>
|
||||
<strong class="date center">{% translate "Date" %}</strong>
|
||||
<strong class="account center">{% translate "Account" %}</strong>
|
||||
<strong class="value center">{% translate "Value" %}</strong>
|
||||
<strong class="diff center">{% translate "Difference" %}</strong>
|
||||
<strong class="diff center">{% translate "Transactions" %}</strong>
|
||||
<strong class="diff center">{% translate "Valid" %}</strong>
|
||||
</div>
|
||||
{% for snap in snapshots %}
|
||||
<div class="snapshot {% cycle 'w' 'g' %}">
|
||||
<span class="attach center">
|
||||
{% if snap.file %}
|
||||
<a href="{{ snap.file.url }}">
|
||||
<i class="fa fa-paperclip"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="date num center">
|
||||
<a href="{% url 'snapshot' snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
|
||||
</span>
|
||||
<span class="account text center">
|
||||
<i class="fa fa-{{ snap.account.icon }}"></i>
|
||||
<a href="{% url 'account' snap.account.id %}">{{ snap.account }}</a>
|
||||
</span>
|
||||
<span class="value num right">{{ snap.value|value }}</span>
|
||||
<span class="diff num right">{{ snap.diff|pmvalue }}</span>
|
||||
{% with sum=snap.sum %}
|
||||
<span class="sum num right">{{ sum|pmvalue }}</span>
|
||||
<span class="valid center">
|
||||
{% if sum == snap.diff %}
|
||||
<i class="fa fa-check green"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-xmark red"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if snapshots_url %}
|
||||
<div class="full-line {% cycle "w" "g" %}">
|
||||
<a href="{{ snapshots_url }}">{% translate "View all statements" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -45,4 +45,9 @@
|
|||
<span class="description text">{{ trans.description }}</span>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% if transactions_url %}
|
||||
<div class="full-line {% cycle "w" "g" %}">
|
||||
<a href="{{ transactions_url }}">{% translate "View all transactions" %}</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
|
@ -1,43 +0,0 @@
|
|||
{% load main_extras %}
|
||||
{% load i18n %}
|
||||
<div id="snapshots" class="table col1-6">
|
||||
<div class="header">
|
||||
<strong class="attach center"><i class="fa fa-paperclip"></i></strong>
|
||||
<strong class="date center">{% translate "Date" %}</strong>
|
||||
<strong class="account center">{% translate "Account" %}</strong>
|
||||
<strong class="value center">{% translate "Value" %}</strong>
|
||||
<strong class="diff center">{% translate "Difference" %}</strong>
|
||||
<strong class="diff center">{% translate "Transactions" %}</strong>
|
||||
<strong class="diff center">{% translate "Valid" %}</strong>
|
||||
</div>
|
||||
{% for snap in snapshots %}
|
||||
<div class="snapshot {% cycle 'w' 'g' %}">
|
||||
<span class="attach center">
|
||||
{% if snap.file %}
|
||||
<a href="{{ snap.file.url }}">
|
||||
<i class="fa fa-paperclip"></i>
|
||||
</a>
|
||||
{% endif %}
|
||||
</span>
|
||||
<span class="date num center">
|
||||
<a href="{% url 'snapshot' snap.id %}">{{ snap.date|date:"Y-m-d" }}</a>
|
||||
</span>
|
||||
<span class="account text center">
|
||||
<i class="fa fa-{{ snap.account.icon }}"></i>
|
||||
<a href="{% url 'account' snap.account.id %}">{{ snap.account }}</a>
|
||||
</span>
|
||||
<span class="value num right">{{ snap.value|value }}</span>
|
||||
<span class="diff num right">{{ snap.diff|pmvalue }}</span>
|
||||
{% with sum=snap.sum %}
|
||||
<span class="sum num right">{{ sum|pmvalue }}</span>
|
||||
<span class="valid center">
|
||||
{% if sum == snap.diff %}
|
||||
<i class="fa fa-check green"></i>
|
||||
{% else %}
|
||||
<i class="fa fa-xmark red"></i>
|
||||
{% endif %}
|
||||
</span>
|
||||
{% endwith %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
|
@ -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 {
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue