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 ""
|
||||
"Project-Id-Version: \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"
|
||||
"Last-Translator: Edgar P. Burkhart <traduction@edgarpierre.fr>\n"
|
||||
"Language-Team: \n"
|
||||
|
@ -37,6 +37,22 @@ msgstr "Défaut"
|
|||
msgid "Accounts"
|
||||
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
|
||||
msgid "Create account"
|
||||
msgstr "Créer un compte"
|
||||
|
@ -44,15 +60,3 @@ msgstr "Créer un compte"
|
|||
#: .\account\templates\account\account_form.html:8
|
||||
msgid "New account"
|
||||
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" %}
|
||||
{% 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 = [
|
||||
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(
|
||||
"<account>/transactions",
|
||||
views.AccountTListView.as_view(),
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse_lazy
|
||||
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 transaction.views import TransactionListView
|
||||
|
||||
|
@ -50,6 +55,36 @@ class AccountDeleteView(NummiDeleteView):
|
|||
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:
|
||||
def get_queryset(self):
|
||||
self.account = get_object_or_404(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue