Separate detail and edit view for account
This commit is contained in:
parent
6bd83feafe
commit
218a6aca6f
12 changed files with 135 additions and 68 deletions
Binary file not shown.
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-01-02 15:52+0100\n"
|
"POT-Creation-Date: 2024-01-04 16:04+0100\n"
|
||||||
"PO-Revision-Date: 2023-04-22 15:17+0200\n"
|
"PO-Revision-Date: 2023-04-22 15:17+0200\n"
|
||||||
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
|
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
@ -37,6 +37,22 @@ msgstr "Défaut"
|
||||||
msgid "Accounts"
|
msgid "Accounts"
|
||||||
msgstr "Comptes"
|
msgstr "Comptes"
|
||||||
|
|
||||||
|
#: .\account\templates\account\account_detail.html:15
|
||||||
|
msgid "Edit account"
|
||||||
|
msgstr "Modifier le compte"
|
||||||
|
|
||||||
|
#: .\account\templates\account\account_detail.html:17
|
||||||
|
msgid "Statements"
|
||||||
|
msgstr "Relevés"
|
||||||
|
|
||||||
|
#: .\account\templates\account\account_detail.html:21
|
||||||
|
msgid "Transactions"
|
||||||
|
msgstr "Transactions"
|
||||||
|
|
||||||
|
#: .\account\templates\account\account_detail.html:26
|
||||||
|
msgid "History"
|
||||||
|
msgstr "Historique"
|
||||||
|
|
||||||
#: .\account\templates\account\account_form.html:5
|
#: .\account\templates\account\account_form.html:5
|
||||||
msgid "Create account"
|
msgid "Create account"
|
||||||
msgstr "Créer un compte"
|
msgstr "Créer un compte"
|
||||||
|
@ -44,15 +60,3 @@ msgstr "Créer un compte"
|
||||||
#: .\account\templates\account\account_form.html:8
|
#: .\account\templates\account\account_form.html:8
|
||||||
msgid "New account"
|
msgid "New account"
|
||||||
msgstr "Nouveau compte"
|
msgstr "Nouveau compte"
|
||||||
|
|
||||||
#: .\account\templates\account\account_form.html:14
|
|
||||||
msgid "Statements"
|
|
||||||
msgstr "Relevés"
|
|
||||||
|
|
||||||
#: .\account\templates\account\account_form.html:18
|
|
||||||
msgid "Transactions"
|
|
||||||
msgstr "Transactions"
|
|
||||||
|
|
||||||
#: .\account\templates\account\account_form.html:23
|
|
||||||
msgid "History"
|
|
||||||
msgstr "Historique"
|
|
||||||
|
|
30
nummi/account/templates/account/account_detail.html
Normal file
30
nummi/account/templates/account/account_detail.html
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{% extends "main/base.html" %}
|
||||||
|
{% load main_extras %}
|
||||||
|
{% load i18n %}
|
||||||
|
{% block title %}{{ object }} – {{ block.super }}{% endblock %}
|
||||||
|
{% block link %}
|
||||||
|
{{ block.super }}
|
||||||
|
{% css "main/css/form.css" %}
|
||||||
|
{% css "main/css/table.css" %}
|
||||||
|
{% css "main/css/plot.css" %}
|
||||||
|
{% endblock %}
|
||||||
|
{% block body %}
|
||||||
|
<h2>{{ object.icon|remix }}{{ object }}</h2>
|
||||||
|
<p>
|
||||||
|
<a href="{% url "edit_account" object.pk %}">{% translate "Edit account" %}</a>
|
||||||
|
</p>
|
||||||
|
<section>
|
||||||
|
<h3>{% translate "Statements" %}</h3>
|
||||||
|
{% include "statement/statement_table.html" %}
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<h3>{% translate "Transactions" %}</h3>
|
||||||
|
{% include "transaction/transaction_table.html" %}
|
||||||
|
</section>
|
||||||
|
{% if history %}
|
||||||
|
<section>
|
||||||
|
<h3>{% translate "History" %}</h3>
|
||||||
|
{% include "history/plot.html" %}
|
||||||
|
</section>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
|
@ -8,21 +8,3 @@
|
||||||
{% translate "New account" %}
|
{% translate "New account" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
|
{% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
|
||||||
{% block tables %}
|
|
||||||
{% if not form.instance|adding %}
|
|
||||||
<section>
|
|
||||||
<h3>{% translate "Statements" %}</h3>
|
|
||||||
{% include "statement/statement_table.html" %}
|
|
||||||
</section>
|
|
||||||
<section>
|
|
||||||
<h3>{% translate "Transactions" %}</h3>
|
|
||||||
{% include "transaction/transaction_table.html" %}
|
|
||||||
</section>
|
|
||||||
{% if history %}
|
|
||||||
<section>
|
|
||||||
<h3>{% translate "History" %}</h3>
|
|
||||||
{% include "history/plot.html" %}
|
|
||||||
</section>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -6,7 +6,8 @@ from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("new", views.AccountCreateView.as_view(), name="new_account"),
|
path("new", views.AccountCreateView.as_view(), name="new_account"),
|
||||||
path("<account>", views.AccountUpdateView.as_view(), name="account"),
|
path("<account>", views.AccountDetailView.as_view(), name="account"),
|
||||||
|
path("<account>/edit", views.AccountUpdateView.as_view(), name="edit_account"),
|
||||||
path(
|
path(
|
||||||
"<account>/transactions",
|
"<account>/transactions",
|
||||||
views.AccountTListView.as_view(),
|
views.AccountTListView.as_view(),
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse_lazy
|
from django.urls import reverse_lazy
|
||||||
from history.utils import history
|
from history.utils import history
|
||||||
from main.views import NummiCreateView, NummiDeleteView, NummiUpdateView
|
from main.views import (
|
||||||
|
NummiCreateView,
|
||||||
|
NummiDeleteView,
|
||||||
|
NummiDetailView,
|
||||||
|
NummiUpdateView,
|
||||||
|
)
|
||||||
from statement.views import StatementListView
|
from statement.views import StatementListView
|
||||||
from transaction.views import TransactionListView
|
from transaction.views import TransactionListView
|
||||||
|
|
||||||
|
@ -50,6 +55,36 @@ class AccountDeleteView(NummiDeleteView):
|
||||||
pk_url_kwarg = "account"
|
pk_url_kwarg = "account"
|
||||||
|
|
||||||
|
|
||||||
|
class AccountDetailView(NummiDetailView):
|
||||||
|
model = Account
|
||||||
|
pk_url_kwarg = "account"
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
_max = 8
|
||||||
|
data = super().get_context_data(**kwargs)
|
||||||
|
account = data.get("object")
|
||||||
|
|
||||||
|
_transactions = account.transaction_set.all()
|
||||||
|
if _transactions.count() > _max:
|
||||||
|
data["transactions_url"] = reverse_lazy(
|
||||||
|
"account_transactions", args=(account.pk,)
|
||||||
|
)
|
||||||
|
_statements = account.statement_set.all()
|
||||||
|
if _statements.count() > _max:
|
||||||
|
data["statements_url"] = reverse_lazy(
|
||||||
|
"account_statements", args=(account.pk,)
|
||||||
|
)
|
||||||
|
|
||||||
|
return data | {
|
||||||
|
"transactions": _transactions[:8],
|
||||||
|
"new_statement_url": reverse_lazy(
|
||||||
|
"new_statement", kwargs={"account": account.pk}
|
||||||
|
),
|
||||||
|
"statements": _statements[:8],
|
||||||
|
"history": history(account.transaction_set),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class AccountMixin:
|
class AccountMixin:
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
self.account = get_object_or_404(
|
self.account = get_object_or_404(
|
||||||
|
|
Binary file not shown.
|
@ -7,7 +7,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: \n"
|
"Project-Id-Version: \n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2024-01-03 15:51+0100\n"
|
"POT-Creation-Date: 2024-01-04 16:04+0100\n"
|
||||||
"PO-Revision-Date: 2023-04-23 08:03+0200\n"
|
"PO-Revision-Date: 2023-04-23 08:03+0200\n"
|
||||||
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
|
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
|
||||||
"Language-Team: \n"
|
"Language-Team: \n"
|
||||||
|
@ -37,37 +37,21 @@ msgstr "Relevés"
|
||||||
msgid "Transactions"
|
msgid "Transactions"
|
||||||
msgstr "Transactions"
|
msgstr "Transactions"
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:51 .\main\templates\main\index.html:39
|
#: .\main\templates\main\base.html:51 .\main\templates\main\list.html:10
|
||||||
msgid "Create account"
|
|
||||||
msgstr "Créer un compte"
|
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:56
|
|
||||||
msgid "Create statement"
|
|
||||||
msgstr "Créer un relevé"
|
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:61
|
|
||||||
msgid "Create category"
|
|
||||||
msgstr "Créer une catégorie"
|
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:66
|
|
||||||
msgid "Create transaction"
|
|
||||||
msgstr "Créer une transaction"
|
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:71 .\main\templates\main\list.html:10
|
|
||||||
#: .\main\templates\main\list.html:34
|
#: .\main\templates\main\list.html:34
|
||||||
msgid "Search"
|
msgid "Search"
|
||||||
msgstr "Rechercher"
|
msgstr "Rechercher"
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:74
|
#: .\main\templates\main\base.html:54
|
||||||
msgid "Log out"
|
msgid "Log out"
|
||||||
msgstr "Se déconnecter"
|
msgstr "Se déconnecter"
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:79 .\main\templates\main\form\login.html:6
|
#: .\main\templates\main\base.html:59 .\main\templates\main\form\login.html:6
|
||||||
#: .\main\templates\main\login.html:11
|
#: .\main\templates\main\login.html:11
|
||||||
msgid "Log in"
|
msgid "Log in"
|
||||||
msgstr "Se connecter"
|
msgstr "Se connecter"
|
||||||
|
|
||||||
#: .\main\templates\main\base.html:85
|
#: .\main\templates\main\base.html:65
|
||||||
#, python-format
|
#, python-format
|
||||||
msgid "Logged in as <strong>%(user)s</strong>"
|
msgid "Logged in as <strong>%(user)s</strong>"
|
||||||
msgstr "Connecté en tant que <strong>%(user)s</strong>"
|
msgstr "Connecté en tant que <strong>%(user)s</strong>"
|
||||||
|
@ -117,22 +101,39 @@ msgstr "Compte"
|
||||||
msgid "Balance"
|
msgid "Balance"
|
||||||
msgstr "Solde"
|
msgstr "Solde"
|
||||||
|
|
||||||
#: .\main\templates\main\index.html:32
|
#: .\main\templates\main\index.html:19 .\main\templates\main\index.html:30
|
||||||
|
msgid "Edit"
|
||||||
|
msgstr "Modifier"
|
||||||
|
|
||||||
|
#: .\main\templates\main\index.html:34
|
||||||
msgid "No account"
|
msgid "No account"
|
||||||
msgstr "Aucun compte"
|
msgstr "Aucun compte"
|
||||||
|
|
||||||
#: .\main\templates\main\index.html:47
|
#: .\main\templates\main\index.html:41
|
||||||
|
msgid "Create account"
|
||||||
|
msgstr "Créer un compte"
|
||||||
|
|
||||||
|
#: .\main\templates\main\index.html:48
|
||||||
msgid "Categories"
|
msgid "Categories"
|
||||||
msgstr "Catégories"
|
msgstr "Catégories"
|
||||||
|
|
||||||
#: .\main\templates\main\index.html:53
|
#: .\main\templates\main\index.html:54
|
||||||
msgid "No category"
|
msgid "Create category"
|
||||||
msgstr "Aucune catégorie"
|
msgstr "Créer une catégorie"
|
||||||
|
|
||||||
#: .\main\templates\main\index.html:62
|
#: .\main\templates\main\index.html:61
|
||||||
msgid "History"
|
msgid "History"
|
||||||
msgstr "Historique"
|
msgstr "Historique"
|
||||||
|
|
||||||
#: .\main\views.py:68
|
#: .\main\views.py:69
|
||||||
msgid "was created successfully"
|
msgid "was created successfully"
|
||||||
msgstr "a été créé avec succès"
|
msgstr "a été créé avec succès"
|
||||||
|
|
||||||
|
#~ msgid "Create statement"
|
||||||
|
#~ msgstr "Créer un relevé"
|
||||||
|
|
||||||
|
#~ msgid "Create transaction"
|
||||||
|
#~ msgstr "Créer une transaction"
|
||||||
|
|
||||||
|
#~ msgid "No category"
|
||||||
|
#~ msgstr "Aucune catégorie"
|
||||||
|
|
|
@ -9,6 +9,7 @@ form {
|
||||||
> table > tbody > tr > th {
|
> table > tbody > tr > th {
|
||||||
background: var(--bg-01);
|
background: var(--bg-01);
|
||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
|
border-right: 1px solid var(--gray);
|
||||||
}
|
}
|
||||||
tbody :is(input, select, textarea) {
|
tbody :is(input, select, textarea) {
|
||||||
font: inherit;
|
font: inherit;
|
||||||
|
|
|
@ -234,21 +234,25 @@ footer {
|
||||||
&.green,
|
&.green,
|
||||||
&.red,
|
&.red,
|
||||||
&.white {
|
&.white {
|
||||||
color: var(--bg);
|
|
||||||
&.green {
|
&.green {
|
||||||
background: var(--green);
|
background: var(--green);
|
||||||
|
color: var(--bg);
|
||||||
}
|
}
|
||||||
&.red {
|
&.red {
|
||||||
background: var(--red);
|
background: var(--red);
|
||||||
|
color: var(--bg);
|
||||||
}
|
}
|
||||||
&.white {
|
&.white {
|
||||||
background: var(--bg-01);
|
background: var(--bg-01);
|
||||||
color: var(--text);
|
|
||||||
}
|
}
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
height: 1.5rem;
|
height: 1.5em;
|
||||||
width: 1.5rem;
|
width: 1.5em;
|
||||||
line-height: 1.5rem;
|
line-height: 1.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 & {
|
||||||
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2">{% translate "Account" %}</th>
|
<th colspan="2">{% translate "Account" %}</th>
|
||||||
<th>{% translate "Balance" %}</th>
|
<th>{% translate "Balance" %}</th>
|
||||||
|
<th>{% translate "Edit" %}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -26,16 +27,19 @@
|
||||||
<a href="{{ acc.get_absolute_url }}">{{ acc }}</a>
|
<a href="{{ acc.get_absolute_url }}">{{ acc }}</a>
|
||||||
</th>
|
</th>
|
||||||
<td class="value">{{ acc.statement_set.first.value|value }}</td>
|
<td class="value">{{ acc.statement_set.first.value|value }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="{% url "edit_account" acc.pk %}">{% translate "Edit" %}</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="empty" colspan="3">{% translate "No account" %}</td>
|
<td class="empty" colspan="4">{% translate "No account" %}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr class="new">
|
<tr class="new">
|
||||||
<td colspan="3">
|
<td colspan="4">
|
||||||
<a href="{% url "new_account" %}">{% translate "Create account" %}</a>
|
<a href="{% url "new_account" %}">{% translate "Create account" %}</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -9,6 +9,7 @@ from django.utils.translation import gettext as _
|
||||||
from django.views.generic import (
|
from django.views.generic import (
|
||||||
CreateView,
|
CreateView,
|
||||||
DeleteView,
|
DeleteView,
|
||||||
|
DetailView,
|
||||||
ListView,
|
ListView,
|
||||||
TemplateView,
|
TemplateView,
|
||||||
UpdateView,
|
UpdateView,
|
||||||
|
@ -76,6 +77,10 @@ class NummiUpdateView(UserMixin, UpdateView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class NummiDetailView(UserMixin, DetailView):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class NummiDeleteView(UserMixin, DeleteView):
|
class NummiDeleteView(UserMixin, DeleteView):
|
||||||
template_name = "main/confirm_delete.html"
|
template_name = "main/confirm_delete.html"
|
||||||
success_url = reverse_lazy("index")
|
success_url = reverse_lazy("index")
|
||||||
|
|
Loading…
Reference in a new issue