Create account list view
This commit is contained in:
parent
8575f43475
commit
57d5330d75
12 changed files with 105 additions and 59 deletions
17
nummi/account/templates/account/account_list.html
Normal file
17
nummi/account/templates/account/account_list.html
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{% extends "main/list.html" %}
|
||||||
|
{% load i18n main_extras account_extras %}
|
||||||
|
{% block link %}
|
||||||
|
{{ block.super }}
|
||||||
|
{% css "main/css/table.css" %}
|
||||||
|
{% css "main/css/plot.css" %}
|
||||||
|
{% js "main/js/index.js" %}
|
||||||
|
{% endblock link %}
|
||||||
|
{% block name %}
|
||||||
|
{% translate "Account" %}
|
||||||
|
{% endblock name %}
|
||||||
|
{% block h2 %}
|
||||||
|
{% translate "Accounts" %}
|
||||||
|
{% endblock h2 %}
|
||||||
|
{% block table %}
|
||||||
|
<div class="split">{% account_table accounts %}</div>
|
||||||
|
{% endblock table %}
|
41
nummi/account/templates/account/account_table.html
Normal file
41
nummi/account/templates/account/account_table.html
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{% load i18n main_extras %}
|
||||||
|
<dl class="accounts">
|
||||||
|
{% for acc in accounts %}
|
||||||
|
<div class="account {% if acc.archived %}archived{% endif %}">
|
||||||
|
<dt>
|
||||||
|
<a href="{{ acc.get_absolute_url }}">{{ acc.icon|remix }}{{ acc }}</a>
|
||||||
|
</dt>
|
||||||
|
<dd class="value">
|
||||||
|
{% if acc.statement_set.first %}{{ acc.statement_set.first.value|value }}{% endif %}
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% if index %}
|
||||||
|
<div class="more account">
|
||||||
|
<dt>
|
||||||
|
<a href="{% url "accounts" %}">{{ "gallery-view"|remixnl }}{% translate "All accounts" %}</a>
|
||||||
|
</dt>
|
||||||
|
{% if total %}
|
||||||
|
<dd class="value">
|
||||||
|
{{ total|value }}
|
||||||
|
</dd>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="more account">
|
||||||
|
<dt>
|
||||||
|
<label class="wi" for="show-archived-accounts">
|
||||||
|
{{ "archive"|remix }}{% translate "Show archived" %}
|
||||||
|
</label>
|
||||||
|
</dt>
|
||||||
|
<dd>
|
||||||
|
<input type="checkbox" class="show-archived" id="show-archived-accounts" />
|
||||||
|
</dd>
|
||||||
|
</div>
|
||||||
|
<div class="new account">
|
||||||
|
<dt>
|
||||||
|
<a href="{% url "new_account" %}">{{ "add-box"|remix }}{% translate "Create account" %}</a>
|
||||||
|
</dt>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</dl>
|
0
nummi/account/templatetags/__init__.py
Normal file
0
nummi/account/templatetags/__init__.py
Normal file
10
nummi/account/templatetags/account_extras.py
Normal file
10
nummi/account/templatetags/account_extras.py
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.inclusion_tag("account/account_table.html")
|
||||||
|
def account_table(accounts, **kwargs):
|
||||||
|
return kwargs | {
|
||||||
|
"accounts": accounts,
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ from transaction.views import TransactionMonthView, TransactionYearView
|
||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path("list", views.AccountListView.as_view(), name="accounts"),
|
||||||
path("new", views.AccountCreateView.as_view(), name="new_account"),
|
path("new", views.AccountCreateView.as_view(), name="new_account"),
|
||||||
path("<account>", views.AccountDetailView.as_view(), name="account"),
|
path("<account>", views.AccountDetailView.as_view(), name="account"),
|
||||||
path("<account>/edit", views.AccountUpdateView.as_view(), name="edit_account"),
|
path("<account>/edit", views.AccountUpdateView.as_view(), name="edit_account"),
|
||||||
|
|
|
@ -5,6 +5,7 @@ from main.views import (
|
||||||
NummiCreateView,
|
NummiCreateView,
|
||||||
NummiDeleteView,
|
NummiDeleteView,
|
||||||
NummiDetailView,
|
NummiDetailView,
|
||||||
|
NummiListView,
|
||||||
NummiUpdateView,
|
NummiUpdateView,
|
||||||
)
|
)
|
||||||
from statement.views import StatementListView
|
from statement.views import StatementListView
|
||||||
|
@ -66,6 +67,11 @@ class AccountMixin:
|
||||||
return super().get_context_data(**kwargs) | {"account": self.account}
|
return super().get_context_data(**kwargs) | {"account": self.account}
|
||||||
|
|
||||||
|
|
||||||
|
class AccountListView(NummiListView):
|
||||||
|
model = Account
|
||||||
|
context_object_name = "accounts"
|
||||||
|
|
||||||
|
|
||||||
class AccountTListView(AccountMixin, TransactionListView):
|
class AccountTListView(AccountMixin, TransactionListView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -336,12 +336,9 @@ ul.messages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.accounts {
|
dl.accounts {
|
||||||
display: grid;
|
|
||||||
grid-auto-rows: min-content;
|
|
||||||
|
|
||||||
dl {
|
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|
||||||
dt,
|
dt,
|
||||||
dd {
|
dd {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
@ -364,7 +361,6 @@ ul.messages {
|
||||||
&:not(.show-archive) .account.archived {
|
&:not(.show-archive) .account.archived {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ul.statements,
|
ul.statements,
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
let accounts = document.querySelector(".accounts");
|
let accounts = document.querySelector("dl.accounts");
|
||||||
let toggle = accounts.querySelector("input#show-archived-accounts");
|
let toggle = accounts.querySelector("input#show-archived-accounts");
|
||||||
let dl = accounts.querySelector("dl");
|
|
||||||
|
|
||||||
dl.classList.toggle("show-archive", toggle.checked);
|
accounts.classList.toggle("show-archive", toggle.checked);
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
toggle.addEventListener("change", (event) => {
|
toggle.addEventListener("change", (event) => {
|
||||||
dl.classList.toggle("show-archive", toggle.checked);
|
accounts.classList.toggle("show-archive", toggle.checked);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "main/base.html" %}
|
{% extends "main/base.html" %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load main_extras %}
|
{% load main_extras account_extras %}
|
||||||
{% load i18n %}
|
{% load i18n %}
|
||||||
{% block link %}
|
{% block link %}
|
||||||
{{ block.super }}
|
{{ block.super }}
|
||||||
|
@ -10,42 +10,16 @@
|
||||||
{% endblock link %}
|
{% endblock link %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<div class="split">
|
<div class="split">
|
||||||
<section class="accounts">
|
<section>
|
||||||
<h2>{% translate "Accounts" %}</h2>
|
<h2>{% translate "Accounts" %}</h2>
|
||||||
<dl>
|
{% account_table accounts index=True total=accounts|balance %}
|
||||||
{% for acc in accounts %}
|
|
||||||
<div class="account {% if acc.archived %}archived{% endif %}">
|
|
||||||
<dt>
|
|
||||||
<a href="{{ acc.get_absolute_url }}">{{ acc.icon|remix }}{{ acc }}</a>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
{% if acc.statement_set.first %}{{ acc.statement_set.first.value|value }}{% endif %}
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
{% endfor %}
|
|
||||||
<div class="more account">
|
|
||||||
<dt>
|
|
||||||
<label class="wi" for="show-archived-accounts">
|
|
||||||
{{ "archive"|remix }}{% translate "Show archived" %}
|
|
||||||
</label>
|
|
||||||
</dt>
|
|
||||||
<dd>
|
|
||||||
<input type="checkbox" class="show-archived" id="show-archived-accounts" />
|
|
||||||
</dd>
|
|
||||||
</div>
|
|
||||||
<div class="new account">
|
|
||||||
<dt>
|
|
||||||
<a href="{% url "new_account" %}">{{ "add-box"|remix }}{% translate "Create account" %}</a>
|
|
||||||
</dt>
|
|
||||||
</div>
|
|
||||||
</dl>
|
|
||||||
</section>
|
</section>
|
||||||
<section class="statements">
|
<section>
|
||||||
<h2>{% translate "Statements" %}</h2>
|
<h2>{% translate "Statements" %}</h2>
|
||||||
{% include "statement/statement_table.html" %}
|
{% include "statement/statement_table.html" %}
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
<section class="categories">
|
<section>
|
||||||
<h2>{% translate "Categories" %}</h2>
|
<h2>{% translate "Categories" %}</h2>
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -105,4 +105,4 @@ class LogoutView(auth_views.LogoutView):
|
||||||
|
|
||||||
|
|
||||||
class NummiListView(UserMixin, ListView):
|
class NummiListView(UserMixin, ListView):
|
||||||
paginate_by = 96
|
pass
|
||||||
|
|
|
@ -84,6 +84,7 @@ class StatementDetailView(NummiDetailView):
|
||||||
class StatementListView(NummiListView):
|
class StatementListView(NummiListView):
|
||||||
model = Statement
|
model = Statement
|
||||||
context_object_name = "statements"
|
context_object_name = "statements"
|
||||||
|
paginate_by = 32
|
||||||
|
|
||||||
|
|
||||||
class StatementMixin:
|
class StatementMixin:
|
||||||
|
|
|
@ -124,6 +124,7 @@ class InvoiceDeleteView(NummiDeleteView):
|
||||||
class TransactionListView(NummiListView):
|
class TransactionListView(NummiListView):
|
||||||
model = Transaction
|
model = Transaction
|
||||||
context_object_name = "transactions"
|
context_object_name = "transactions"
|
||||||
|
paginate_by = 50
|
||||||
|
|
||||||
|
|
||||||
class TransactionACMixin:
|
class TransactionACMixin:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue