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
|
||||
|
||||
urlpatterns = [
|
||||
path("list", views.AccountListView.as_view(), name="accounts"),
|
||||
path("new", views.AccountCreateView.as_view(), name="new_account"),
|
||||
path("<account>", views.AccountDetailView.as_view(), name="account"),
|
||||
path("<account>/edit", views.AccountUpdateView.as_view(), name="edit_account"),
|
||||
|
|
|
@ -5,6 +5,7 @@ from main.views import (
|
|||
NummiCreateView,
|
||||
NummiDeleteView,
|
||||
NummiDetailView,
|
||||
NummiListView,
|
||||
NummiUpdateView,
|
||||
)
|
||||
from statement.views import StatementListView
|
||||
|
@ -66,6 +67,11 @@ class AccountMixin:
|
|||
return super().get_context_data(**kwargs) | {"account": self.account}
|
||||
|
||||
|
||||
class AccountListView(NummiListView):
|
||||
model = Account
|
||||
context_object_name = "accounts"
|
||||
|
||||
|
||||
class AccountTListView(AccountMixin, TransactionListView):
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue