parent
acd83704af
commit
057734afd3
6 changed files with 111 additions and 44 deletions
|
@ -43,46 +43,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if snapshots %}
|
{% if snapshots %}
|
||||||
<h2>{% translate "Snapshots" %}</h2>
|
<h2>{% translate "Snapshots" %}</h2>
|
||||||
<div id="snapshots" class="table col1-6">
|
{% snapshot_table snapshots %}
|
||||||
<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>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
36
nummi/main/templates/main/snapshots.html
Normal file
36
nummi/main/templates/main/snapshots.html
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{% extends "main/base.html" %}
|
||||||
|
{% load static %}
|
||||||
|
{% load main_extras %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block link %}
|
||||||
|
{{ block.super }}
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="{% static 'main/css/table.css' %}"
|
||||||
|
type="text/css"/>
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="{% static 'main/css/page.css' %}"
|
||||||
|
type="text/css"/>
|
||||||
|
{% endblock %}
|
||||||
|
{% block body %}
|
||||||
|
<h1>{% translate "Statements" %}</h1>
|
||||||
|
{% if snapshots %}
|
||||||
|
{% snapshot_table snapshots %}
|
||||||
|
{% if page_obj %}
|
||||||
|
<div class="pagination">
|
||||||
|
<span class="step-links">
|
||||||
|
{% if page_obj.has_previous %}
|
||||||
|
<a href="?page=1">↞</a>
|
||||||
|
<a href="?page={{ page_obj.previous_page_number }}">←</a>
|
||||||
|
{% endif %}
|
||||||
|
<span class="current">{{ page_obj.number }}/{{ page_obj.paginator.num_pages }}</span>
|
||||||
|
{% if page_obj.has_next %}
|
||||||
|
<a href="?page={{ page_obj.next_page_number }}">→</a>
|
||||||
|
<a href="?page={{ page_obj.paginator.num_pages }}">↠</a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<p>{% translate "No snapshots to show" %}</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
43
nummi/main/templates/main/tag/snapshot_table.html
Normal file
43
nummi/main/templates/main/tag/snapshot_table.html
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
{% 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>
|
|
@ -33,6 +33,11 @@ def transaction_table(transactions):
|
||||||
return {"transactions": 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")
|
@register.inclusion_tag("main/tag/form_buttons.html")
|
||||||
def form_buttons(instance):
|
def form_buttons(instance):
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -7,6 +7,7 @@ urlpatterns = [
|
||||||
path("login", views.LoginView.as_view(), name="login"),
|
path("login", views.LoginView.as_view(), name="login"),
|
||||||
path("logout", views.LogoutView.as_view(), name="logout"),
|
path("logout", views.LogoutView.as_view(), name="logout"),
|
||||||
path("transactions", views.TransactionListView.as_view(), name="transactions"),
|
path("transactions", views.TransactionListView.as_view(), name="transactions"),
|
||||||
|
path("snapshots", views.SnapshotListView.as_view(), name="snapshots"),
|
||||||
path("account", views.AccountCreateView.as_view(), name="account"),
|
path("account", views.AccountCreateView.as_view(), name="account"),
|
||||||
path("transaction", views.TransactionCreateView.as_view(), name="transaction"),
|
path("transaction", views.TransactionCreateView.as_view(), name="transaction"),
|
||||||
path(
|
path(
|
||||||
|
@ -22,6 +23,11 @@ urlpatterns = [
|
||||||
views.AccountTListView.as_view(),
|
views.AccountTListView.as_view(),
|
||||||
name="account_transactions",
|
name="account_transactions",
|
||||||
),
|
),
|
||||||
|
path(
|
||||||
|
"account/<pk>/snapshots",
|
||||||
|
views.AccountSListView.as_view(),
|
||||||
|
name="account_snapshots",
|
||||||
|
),
|
||||||
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
path("transaction/<pk>", views.TransactionUpdateView.as_view(), name="transaction"),
|
||||||
path(
|
path(
|
||||||
"transaction/<transaction_pk>/invoice/<pk>",
|
"transaction/<transaction_pk>/invoice/<pk>",
|
||||||
|
|
|
@ -30,7 +30,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||||
"accounts": Account.objects.filter(user=self.request.user),
|
"accounts": Account.objects.filter(user=self.request.user),
|
||||||
"transactions": Transaction.objects.filter(user=self.request.user)[:10],
|
"transactions": Transaction.objects.filter(user=self.request.user)[:10],
|
||||||
"categories": Category.objects.filter(user=self.request.user),
|
"categories": Category.objects.filter(user=self.request.user),
|
||||||
"snapshots": Snapshot.objects.filter(user=self.request.user),
|
"snapshots": Snapshot.objects.filter(user=self.request.user)[:10],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,18 +173,35 @@ class SnapshotDeleteView(NummiDeleteView):
|
||||||
model = Snapshot
|
model = Snapshot
|
||||||
|
|
||||||
|
|
||||||
class TransactionListView(UserMixin, ListView):
|
class NummiListView(UserMixin, ListView):
|
||||||
paginate_by = 24
|
paginate_by = 24
|
||||||
|
|
||||||
|
|
||||||
|
class TransactionListView(NummiListView):
|
||||||
model = Transaction
|
model = Transaction
|
||||||
template_name = "main/transactions.html"
|
template_name = "main/transactions.html"
|
||||||
context_object_name = "transactions"
|
context_object_name = "transactions"
|
||||||
|
|
||||||
|
|
||||||
class AccountTListView(TransactionListView):
|
class SnapshotListView(NummiListView):
|
||||||
|
model = Snapshot
|
||||||
|
template_name = "main/snapshots.html"
|
||||||
|
context_object_name = "snapshots"
|
||||||
|
|
||||||
|
|
||||||
|
class AccountMixin:
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super().get_queryset().filter(account=self.kwargs.get("pk"))
|
return super().get_queryset().filter(account=self.kwargs.get("pk"))
|
||||||
|
|
||||||
|
|
||||||
|
class AccountTListView(AccountMixin, TransactionListView):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class AccountSListView(AccountMixin, SnapshotListView):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class SnapshotTListView(TransactionListView):
|
class SnapshotTListView(TransactionListView):
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return super().get_queryset().filter(snapshot=self.kwargs.get("pk"))
|
return super().get_queryset().filter(snapshot=self.kwargs.get("pk"))
|
||||||
|
|
Loading…
Reference in a new issue