Compare commits

...

2 Commits

Author SHA1 Message Date
Edgar P. Burkhart 218a6aca6f
Separate detail and edit view for account 2024-01-04 16:05:38 +01:00
Edgar P. Burkhart 6bd83feafe
Update up-down icons 2024-01-04 15:38:53 +01:00
15 changed files with 151 additions and 74 deletions

View File

@ -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"

View 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 %}

View File

@ -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 %}

View File

@ -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(),

View File

@ -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(

View File

@ -70,7 +70,7 @@
{% endif %} {% endif %}
{% if m %} {% if m %}
<td class="{% if m.sum > 0 %}p{% else %}m{% endif %}" <td class="{% if m.sum > 0 %}p{% else %}m{% endif %}"
style="background-color: color-mix(in hsl, currentcolor {% calendar_opacity m.sum history.max.sum %}, white)" style="--opacity: {% calendar_opacity m.sum history.max.sum %}"
title="{{ m.sum|pmrvalue }}">{% up_down_icon m.sum %}</td> title="{{ m.sum|pmrvalue }}">{% up_down_icon m.sum %}</td>
{% else %} {% else %}
<td></td> <td></td>

View File

@ -30,11 +30,11 @@ def empty_calendar_cells_end(n):
@register.simple_tag @register.simple_tag
def up_down_icon(val): def up_down_icon(val):
if val > 0: if val > 0:
return remix("arrow-up-s", "green w") return remix("arrow-up-s", "green")
elif val < 0: elif val < 0:
return remix("arrow-down-s", "red w") return remix("arrow-down-s", "red")
return "" return remix("equal", "white")
@register.simple_tag @register.simple_tag

View File

@ -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"

View File

@ -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;

View File

@ -232,18 +232,27 @@ footer {
font-weight: normal; font-weight: normal;
&.green, &.green,
&.red { &.red,
color: white; &.white {
&.green { &.green {
background: var(--green); background: var(--green);
color: var(--bg);
} }
&.red { &.red {
background: var(--red); background: var(--red);
color: var(--bg);
}
&.white {
background: var(--bg-01);
} }
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;
} }
} }

View File

@ -101,11 +101,16 @@ table.full-width col.bar {
td { td {
text-align: center; text-align: center;
background-color: color-mix(
in hsl,
var(--td-bg, var(--bg)) var(--opacity),
var(--bg)
);
&.p { &.p {
color: var(--green); --td-bg: var(--green);
} }
&.m { &.m {
color: var(--red); --td-bg: var(--red);
} }
} }
} }

View File

@ -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>

View File

@ -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")