From 218a6aca6f340fe4baf24486a0f7b0d7bf81b6f7 Mon Sep 17 00:00:00 2001 From: "Edgar P. Burkhart" Date: Thu, 4 Jan 2024 16:05:38 +0100 Subject: [PATCH] Separate detail and edit view for account --- .../locale/fr_FR/LC_MESSAGES/django.mo | Bin 762 -> 810 bytes .../locale/fr_FR/LC_MESSAGES/django.po | 30 +++++---- .../templates/account/account_detail.html | 30 +++++++++ .../templates/account/account_form.html | 18 ------ nummi/account/urls.py | 3 +- nummi/account/views.py | 37 +++++++++++- nummi/main/locale/fr_FR/LC_MESSAGES/django.mo | Bin 1828 -> 1687 bytes nummi/main/locale/fr_FR/LC_MESSAGES/django.po | 57 +++++++++--------- nummi/main/static/main/css/form.css | 1 + nummi/main/static/main/css/main.css | 14 +++-- nummi/main/templates/main/index.html | 8 ++- nummi/main/views.py | 5 ++ 12 files changed, 135 insertions(+), 68 deletions(-) create mode 100644 nummi/account/templates/account/account_detail.html diff --git a/nummi/account/locale/fr_FR/LC_MESSAGES/django.mo b/nummi/account/locale/fr_FR/LC_MESSAGES/django.mo index 1829874bb523006c772335f1cf9474c1f6b15411..d0a97cf8b790f1183168d8f4c957f9c7d6f0f41f 100644 GIT binary patch delta 336 zcmXYrF-yZh7>4g+lBP|SHgvRjPEv5{;^N}ap@XYqpN_F5ljNk;Gz^SX>KSKKw&(gd!OKXeQ=Z`D>rjy$u&F}N< Q#XM%l7Eh}(tG~VLKNxZ#NdN!< delta 289 zcmXxfEfWDz6vpv$*g?5;EO z%x~_Ud(S=h7<~Qs+48nV)kue|Nknc$6*{vLMp(u+Hn5lP4|7N8u|LV3qI%A-iVLjc z68mID0<+k5h3tVnh8#HL>oe-&1vzL}EaDwCzymeV3)T3I^h`_VDntXYotB2vNB*U| WzBRL@9#REK*9}f{w{gj*F#Z8PtQB+s diff --git a/nummi/account/locale/fr_FR/LC_MESSAGES/django.po b/nummi/account/locale/fr_FR/LC_MESSAGES/django.po index e2b3dd5..e0baa15 100644 --- a/nummi/account/locale/fr_FR/LC_MESSAGES/django.po +++ b/nummi/account/locale/fr_FR/LC_MESSAGES/django.po @@ -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 \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" diff --git a/nummi/account/templates/account/account_detail.html b/nummi/account/templates/account/account_detail.html new file mode 100644 index 0000000..419669e --- /dev/null +++ b/nummi/account/templates/account/account_detail.html @@ -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 %} +

{{ object.icon|remix }}{{ object }}

+

+ {% translate "Edit account" %} +

+
+

{% translate "Statements" %}

+ {% include "statement/statement_table.html" %} +
+
+

{% translate "Transactions" %}

+ {% include "transaction/transaction_table.html" %} +
+ {% if history %} +
+

{% translate "History" %}

+ {% include "history/plot.html" %} +
+ {% endif %} +{% endblock %} diff --git a/nummi/account/templates/account/account_form.html b/nummi/account/templates/account/account_form.html index eaba124..b24800e 100644 --- a/nummi/account/templates/account/account_form.html +++ b/nummi/account/templates/account/account_form.html @@ -8,21 +8,3 @@ {% translate "New account" %} {% endblock %} {% block h2 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %} -{% block tables %} - {% if not form.instance|adding %} -
-

{% translate "Statements" %}

- {% include "statement/statement_table.html" %} -
-
-

{% translate "Transactions" %}

- {% include "transaction/transaction_table.html" %} -
- {% if history %} -
-

{% translate "History" %}

- {% include "history/plot.html" %} -
- {% endif %} - {% endif %} -{% endblock %} diff --git a/nummi/account/urls.py b/nummi/account/urls.py index d9b8c14..f6b4f2b 100644 --- a/nummi/account/urls.py +++ b/nummi/account/urls.py @@ -6,7 +6,8 @@ from . import views urlpatterns = [ path("new", views.AccountCreateView.as_view(), name="new_account"), - path("", views.AccountUpdateView.as_view(), name="account"), + path("", views.AccountDetailView.as_view(), name="account"), + path("/edit", views.AccountUpdateView.as_view(), name="edit_account"), path( "/transactions", views.AccountTListView.as_view(), diff --git a/nummi/account/views.py b/nummi/account/views.py index 446ac30..a07bd8b 100644 --- a/nummi/account/views.py +++ b/nummi/account/views.py @@ -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( diff --git a/nummi/main/locale/fr_FR/LC_MESSAGES/django.mo b/nummi/main/locale/fr_FR/LC_MESSAGES/django.mo index c963419eca93ed0d64d1b1c6058b7de5609b7c13..258a1ed85a97ab8bc46848e7e6b7e75135ee0dd7 100644 GIT binary patch delta 694 zcmYk)J1j$C7{>9pEp@58x)h5+8-p0cNJ7|{7)VULkdvU*RH6(gu@gxn!s@bglo&fwyHxT`dt3t0QnN&LF9sFHMoJbSi~{h zb@ewGrhJd}_~`1NT>Tq1QU8w3_~q(rLuOTGzBT{7SQNET%$5656USZs5XLEwq83`h zYFt4kvNcryJVvpI>bH*#c#P_If!$cfM8G$@<3$5MXw?QjaT32#3ykwn{S-!U2J3JE zH7Urjh&#zpQ1KYcI7Kdt{b&*0yV)1_TV^b zfkjmRB&uH)dvOQ#6*Z=vRA@fFK&4$}pFY+_YM??_q{$UJ4VP0noldN4i;&!GOL+F#-`I=p_B~GU*3iWgDrEL Yxm?~`%j9h~oA#EyQg3*xbRPD90g5L*WB>pF delta 821 zcmYk)ziU%b7{>9_Bu&$%X=_?rqc&bTRGY=R)uDq{6qhVYCYKOSHDGSS?Y*K<2!i+z zT#AT8Td+uQv!$C*jDsLbtf3m-bI&dJd*t%#IM44-Pz_&W7WZ)w-=XS!K-K+(Q}`J*|2vN2PfXF@3^4l? zi8P*P*XK}wyg@ZBq>NXwf@<*G8#RB5$wTxv zMZRcd^Ge_))Cw=7j_f*K#EQ#5MHP%uN4tYs$R4WB0iMQ>s4M%1s&|N**TXZIp;=qk z%suoA>J${3tO8tRe*v6SKlF}h<=T~EmZ1h}sv}ouhYD?^z+kienB-H}K=0!*_y0jV z(W-I`y@)!(8Adj4BwmzO0$UBOw-)l*uzqM\n" "Language-Team: \n" @@ -37,37 +37,21 @@ msgstr "Relevés" msgid "Transactions" msgstr "Transactions" -#: .\main\templates\main\base.html:51 .\main\templates\main\index.html:39 -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\base.html:51 .\main\templates\main\list.html:10 #: .\main\templates\main\list.html:34 msgid "Search" msgstr "Rechercher" -#: .\main\templates\main\base.html:74 +#: .\main\templates\main\base.html:54 msgid "Log out" 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 msgid "Log in" msgstr "Se connecter" -#: .\main\templates\main\base.html:85 +#: .\main\templates\main\base.html:65 #, python-format msgid "Logged in as %(user)s" msgstr "Connecté en tant que %(user)s" @@ -117,22 +101,39 @@ msgstr "Compte" msgid "Balance" 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" 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" msgstr "Catégories" -#: .\main\templates\main\index.html:53 -msgid "No category" -msgstr "Aucune catégorie" +#: .\main\templates\main\index.html:54 +msgid "Create category" +msgstr "Créer une catégorie" -#: .\main\templates\main\index.html:62 +#: .\main\templates\main\index.html:61 msgid "History" msgstr "Historique" -#: .\main\views.py:68 +#: .\main\views.py:69 msgid "was created successfully" 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" diff --git a/nummi/main/static/main/css/form.css b/nummi/main/static/main/css/form.css index 1ee72a6..7dc2378 100644 --- a/nummi/main/static/main/css/form.css +++ b/nummi/main/static/main/css/form.css @@ -9,6 +9,7 @@ form { > table > tbody > tr > th { background: var(--bg-01); background-clip: padding-box; + border-right: 1px solid var(--gray); } tbody :is(input, select, textarea) { font: inherit; diff --git a/nummi/main/static/main/css/main.css b/nummi/main/static/main/css/main.css index 35dd9d1..e81f77a 100644 --- a/nummi/main/static/main/css/main.css +++ b/nummi/main/static/main/css/main.css @@ -234,21 +234,25 @@ footer { &.green, &.red, &.white { - color: var(--bg); &.green { background: var(--green); + color: var(--bg); } &.red { background: var(--red); + color: var(--bg); } &.white { background: var(--bg-01); - color: var(--text); } border-radius: var(--radius); - height: 1.5rem; - width: 1.5rem; - line-height: 1.5rem; + height: 1.5em; + width: 1.5em; + line-height: 1.5em; + } + + h2 & { + margin-right: 0.5em; } } diff --git a/nummi/main/templates/main/index.html b/nummi/main/templates/main/index.html index 6a42983..b637297 100644 --- a/nummi/main/templates/main/index.html +++ b/nummi/main/templates/main/index.html @@ -16,6 +16,7 @@ {% translate "Account" %} {% translate "Balance" %} + {% translate "Edit" %} @@ -26,16 +27,19 @@ {{ acc }} {{ acc.statement_set.first.value|value }} + + {% translate "Edit" %} + {% empty %} - {% translate "No account" %} + {% translate "No account" %} {% endfor %} - + {% translate "Create account" %} diff --git a/nummi/main/views.py b/nummi/main/views.py index e1d52a3..a6361ab 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -9,6 +9,7 @@ from django.utils.translation import gettext as _ from django.views.generic import ( CreateView, DeleteView, + DetailView, ListView, TemplateView, UpdateView, @@ -76,6 +77,10 @@ class NummiUpdateView(UserMixin, UpdateView): pass +class NummiDetailView(UserMixin, DetailView): + pass + + class NummiDeleteView(UserMixin, DeleteView): template_name = "main/confirm_delete.html" success_url = reverse_lazy("index")