Use form template

This commit is contained in:
Edgar P. Burkhart 2023-04-20 12:01:22 +02:00
parent 110a699f1a
commit 37bb725f23
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
10 changed files with 154 additions and 226 deletions

View file

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2023-04-20 09:39+0200\n"
"POT-Creation-Date: 2023-04-20 12:00+0200\n"
"PO-Revision-Date: 2022-12-21 17:30+0100\n"
"Last-Translator: edpibu <git@edgarpierre.fr>\n"
"Language-Team: edpibu <git@edgarpierre.fr>\n"
@ -32,19 +32,19 @@ msgstr "Rechercher"
msgid "User"
msgstr "Utilisateur"
#: .\models.py:38 .\models.py:72 .\models.py:80 .\models.py:230
#: .\models.py:38 .\models.py:75 .\models.py:83 .\models.py:239
#: .\templates\main\table\snapshot.html:24
#: .\templates\main\table\transaction.html:35
msgid "Account"
msgstr "Compte"
#: .\models.py:38 .\models.py:90 .\models.py:201 .\models.py:271
#: .\models.py:38 .\models.py:93 .\models.py:210 .\models.py:283
#: .\templates\main\table\invoice.html:9
#: .\templates\main\table\transaction.html:28
msgid "Name"
msgstr "Nom"
#: .\models.py:42 .\models.py:95
#: .\models.py:42 .\models.py:98
msgid "Icon"
msgstr "Icône"
@ -52,113 +52,113 @@ msgstr "Icône"
msgid "Default"
msgstr "Défaut"
#: .\models.py:73 .\templates\main\index.html:16
#: .\models.py:76 .\templates\main\index.html:16
msgid "Accounts"
msgstr "Comptes"
#: .\models.py:90 .\models.py:114 .\models.py:220
#: .\models.py:93 .\models.py:120 .\models.py:229
#: .\templates\main\plot\category.html:14
#: .\templates\main\table\transaction.html:32
msgid "Category"
msgstr "Catégorie"
#: .\models.py:97
#: .\models.py:100
msgid "Budget"
msgstr "Budget"
#: .\models.py:115 .\templates\main\form\snapshot.html:29
#: .\models.py:121 .\templates\main\form\snapshot.html:10
#: .\templates\main\index.html:32
msgid "Categories"
msgstr "Catégories"
#: .\models.py:120
#: .\models.py:126
msgid "End date"
msgstr "Date de fin"
#: .\models.py:122
#: .\models.py:128
msgid "Start date"
msgstr "Date de début"
#: .\models.py:125
#: .\models.py:131
msgid "End value"
msgstr "Valeur de fin"
#: .\models.py:128
#: .\models.py:134
msgid "Start value"
msgstr "Valeur de début"
#: .\models.py:134 .\templates\main\table\snapshot.html:27
#: .\models.py:140 .\templates\main\table\snapshot.html:27
msgid "Difference"
msgstr "Différence"
#: .\models.py:141
#: .\models.py:147
msgid "Transaction difference"
msgstr "Différence des transactions"
#: .\models.py:147 .\models.py:276 .\templates\main\form\fileinput.html:8
#: .\models.py:153 .\models.py:288 .\templates\main\form\fileinput.html:8
#: .\templates\main\table\invoice.html:10
#: .\templates\main\table\invoice.html:21
msgid "File"
msgstr "Fichier"
#: .\models.py:154
#: .\models.py:160
#, python-format
msgid "%(date)s statement"
msgstr "Relevé du %(date)s"
#: .\models.py:194 .\models.py:225
#: .\models.py:203 .\models.py:234
msgid "Statement"
msgstr "Relevé"
#: .\models.py:195 .\templates\main\form\account.html:25
#: .\models.py:204 .\templates\main\form\account.html:7
#: .\templates\main\list\snapshot.html:6 .\templates\main\list\snapshot.html:20
msgid "Statements"
msgstr "Relevés"
#: .\models.py:201 .\models.py:264
#: .\models.py:210 .\models.py:276
msgid "Transaction"
msgstr "Transaction"
#: .\models.py:203
#: .\models.py:212
msgid "Description"
msgstr "Description"
#: .\models.py:205 .\templates\main\table\snapshot.html:26
#: .\models.py:214 .\templates\main\table\snapshot.html:26
#: .\templates\main\table\transaction.html:29
msgid "Value"
msgstr "Valeur"
#: .\models.py:207 .\templates\main\table\snapshot.html:22
#: .\models.py:216 .\templates\main\table\snapshot.html:22
#: .\templates\main\table\transaction.html:27
msgid "Date"
msgstr "Date"
#: .\models.py:208
#: .\models.py:217
msgid "Real date"
msgstr "Date réelle"
#: .\models.py:210 .\templates\main\table\transaction.html:30
#: .\models.py:219 .\templates\main\table\transaction.html:30
msgid "Trader"
msgstr "Commerçant"
#: .\models.py:213
#: .\models.py:222
msgid "Payment"
msgstr "Paiement"
#: .\models.py:265 .\templates\main\base.html:50
#: .\templates\main\form\account.html:29 .\templates\main\form\category.html:25
#: .\templates\main\form\snapshot.html:33 .\templates\main\index.html:26
#: .\models.py:277 .\templates\main\base.html:50
#: .\templates\main\form\account.html:11 .\templates\main\form\category.html:7
#: .\templates\main\form\snapshot.html:14 .\templates\main\index.html:26
#: .\templates\main\list\transaction.html:6
#: .\templates\main\list\transaction.html:23
#: .\templates\main\table\snapshot.html:28
msgid "Transactions"
msgstr "Transactions"
#: .\models.py:271 .\models.py:308
#: .\models.py:283 .\models.py:323
msgid "Invoice"
msgstr "Facture"
#: .\models.py:309 .\templates\main\form\transaction.html:24
#: .\models.py:324 .\templates\main\form\transaction.html:5
msgid "Invoices"
msgstr "Factures"
@ -175,26 +175,26 @@ msgid "Snapshots"
msgstr "Relevés"
#: .\templates\main\base.html:56
msgid "New account"
msgstr "Nouveau compte"
msgid "Create account"
msgstr "Créer compte"
#: .\templates\main\base.html:61
msgid "New snapshot"
msgstr "Nouveau relevé"
msgid "Create snapshot"
msgstr "Créer relevé"
#: .\templates\main\base.html:66
msgid "New category"
msgstr "Nouvelle catégorie"
msgid "Create category"
msgstr "Créer catégorie"
#: .\templates\main\base.html:71 .\templates\main\table\transaction.html:5
msgid "New transaction"
msgstr "Nouvelle transaction"
#: .\templates\main\base.html:71
msgid "Create transaction"
msgstr "Créer transaction"
#: .\templates\main\base.html:79
msgid "Log out"
msgstr "Se déconnecter"
#: .\templates\main\base.html:84 .\templates\main\form\login.html:7
#: .\templates\main\base.html:84 .\templates\main\form\login.html:6
msgid "Log in"
msgstr "Se connecter"
@ -211,25 +211,27 @@ msgstr "Annuler"
msgid "Confirm"
msgstr "Confirmer"
#: .\templates\main\form\account.html:31 .\templates\main\form\category.html:27
#: .\templates\main\form\account.html:13 .\templates\main\form\category.html:9
#: .\templates\main\index.html:28
msgid "History"
msgstr "Historique"
#: .\templates\main\form\base.html:27
msgid "Add another"
msgstr "Continuer à ajouter"
#: .\templates\main\form\base.html:7 .\templates\main\form\base.html:28
#, python-format
msgid "Create %(name)s"
msgstr "Créer %(name)s"
#: .\templates\main\form\base.html:38 .\templates\main\table\invoice.html:11
#: .\templates\main\form\form_base.html:29
#: .\templates\main\table\invoice.html:11
#: .\templates\main\table\invoice.html:24
msgid "Delete"
msgstr "Supprimer"
#: .\templates\main\form\base.html:40
#: .\templates\main\form\form_base.html:31
msgid "Reset"
msgstr "Réinitialiser"
#: .\templates\main\form\base.html:41
#: .\templates\main\form\form_base.html:32
msgid "Save"
msgstr "Enregistrer"
@ -273,9 +275,10 @@ msgstr "Nouveau relevé"
msgid "View all statements"
msgstr "Voir tous les relevés"
#: .\templates\main\table\transaction.html:5
msgid "New transaction"
msgstr "Nouvelle transaction"
#: .\templates\main\table\transaction.html:73
msgid "View all transactions"
msgstr "Voir toutes les transactions"
#~ msgid "Valid"
#~ msgstr "Valide"

View file

@ -53,22 +53,22 @@
<li>
<a href="{% url 'account' %}"
class="{% if request.resolver_match.url_name == 'account' %}cur{% endif %}"
accesskey="a">{% translate "New account" %}</a>
accesskey="a">{% translate "Create account" %}</a>
</li>
<li>
<a href="{% url 'snapshot' %}"
class="{% if request.resolver_match.url_name == 'snapshot' %}cur{% endif %}"
accesskey="s">{% translate "New snapshot" %}</a>
accesskey="s">{% translate "Create snapshot" %}</a>
</li>
<li>
<a href="{% url 'category' %}"
class="{% if request.resolver_match.url_name == 'category' %}cur{% endif %}"
accesskey="c">{% translate "New category" %}</a>
accesskey="c">{% translate "Create category" %}</a>
</li>
<li>
<a href="{% url 'transaction' %}"
class="{% if request.resolver_match.url_name == 'transaction' %}cur{% endif %}"
accesskey="t">{% translate "New transaction" %}</a>
accesskey="t">{% translate "Create transaction" %}</a>
</li>
<li>
<a href="{% url 'search' %}"

View file

@ -1,32 +1,9 @@
{% extends "main/base.html" %}
{% load static %}
{% extends "main/form/base.html" %}
{% load main_extras %}
{% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %}
{% block body %}
{% with account=form.instance %}
{% if account.adding %}
<h1>{% translate "New account" %}</h1>
{% else %}
<h1>{{ account.icon|remix }}{{ account }}</h1>
{% endif %}
<form method="post">
{% csrf_token %}
{{ form }}
</form>
{% if not account.adding %}
{% block h1 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %}
{% if not form.instance.adding %}
<h2>{% translate "Statements" %}</h2>
{% include "main/table/snapshot.html" %}
{% endif %}
@ -36,5 +13,4 @@
<h2>{% translate "History" %}</h2>
{% include "main/plot/history.html" %}
{% endif %}
{% endwith %}
{% endblock %}

View file

@ -0,0 +1,40 @@
{% extends "main/base.html" %}
{% load static %}
{% load main_extras %}
{% load i18n %}
{% block title %}
{% if form.instance.adding %}
{% blocktranslate with name=form.instance|verbose_name|lower %}Create {{ name }}{% endblocktranslate %}
{% else %}
{{ form.instance }}
{% endif %}
Nummi
{% endblock %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %}
{% block body %}
{% with instance=form.instance %}
{% if instance.adding %}
<h1>{% blocktranslate with name=instance|verbose_name|lower %}Create {{ name }}{% endblocktranslate %}</h1>
{% else %}
<h1>
{% block h1 %}{{ instance }}{% endblock %}
</h1>
{% endif %}
<form method="post">
{% csrf_token %}
{{ form }}
</form>
{% block tables %}{% endblock %}
{% endwith %}
{% endblock %}

View file

@ -1,36 +1,12 @@
{% extends "main/base.html" %}
{% load static %}
{% extends "main/form/base.html" %}
{% load main_extras %}
{% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% endblock %}
{% block body %}
{% with category=form.instance %}
{% if category.adding %}
<h1>{% translate "New category" %}</h1>
{% else %}
<h1>{{ category.icon|remix }}{{ category }}</h1>
{% endif %}
<form method="post">
{% csrf_token %}
{{ form }}
</form>
{% if category.transactions %}
{% block h1 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block tables %}
{% if form.instance.transactions %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
<h2>{% translate "History" %}</h2>
{% include "main/plot/history.html" %}
{% endif %}
{% endwith %}
{% endblock %}

View file

@ -1,32 +1 @@
{% extends "main/base.html" %}
{% load static %}
{% load main_extras %}
{% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %}
{% block body %}
{% with invoice=form.instance %}
{% if invoice.adding %}
<h1>{% translate "New invoice" %}</h1>
{% else %}
<h1>{{ invoice }}</h1>
{% endif %}
<p>
<a href="{{ invoice.transaction.get_absolute_url }}">{{ invoice.transaction }}</a>
</p>
{% spaceless %}
<form id="transaction" method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
</form>
{% endspaceless %}
{% endwith %}
{% endblock %}
{% extends "main/form/base.html" %}

View file

@ -1,41 +1,17 @@
{% extends "main/base.html" %}
{% load static %}
{% extends "main/form/base.html" %}
{% load main_extras %}
{% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/plot.css' %}"
type="text/css" />
{% block h1 %}
{{ form.instance.sum|check:form.instance.diff }}
{{ form.instance }}
{% endblock %}
{% block body %}
{% with snapshot=form.instance %}
{% if snapshot.adding %}
<h1>{% translate "New snapshot" %}</h1>
{% else %}
<h1>
<span class="ri-{% if snapshot.sum == snapshot.diff %}check-line green{% else %}close-line red{% endif %}"></span>
{{ snapshot }}
</h1>
{% endif %}
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
</form>
{% block tables %}
{% if categories %}
<h2>{% translate "Categories" %}</h2>
{% include "main/plot/category.html" %}
{% endif %}
{% if not snapshot.adding %}
<h2>{% translate "Transactions" %} ({{ snapshot.sum|pmvalue }} / {{ snapshot.diff|pmvalue }})</h2>
{% if not form.instance.adding %}
<h2>{% translate "Transactions" %} ({{ form.instance.sum|pmvalue }} / {{ form.instance.diff|pmvalue }})</h2>
{% include "main/table/transaction.html" %}
{% endif %}
{% endwith %}
{% endblock %}

View file

@ -1,33 +1,8 @@
{% extends "main/base.html" %}
{% load static %}
{% load main_extras %}
{% extends "main/form/base.html" %}
{% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %}
{% block link %}
{{ block.super }}
<link rel="stylesheet"
href="{% static 'main/css/form.css' %}"
type="text/css" />
<link rel="stylesheet"
href="{% static 'main/css/table.css' %}"
type="text/css" />
{% endblock %}
{% block body %}
{% with transaction=form.instance %}
{% if transaction.adding %}
<h1>{% translate "New transaction" %}</h1>
{% else %}
<h1>{{ form.instance }}</h1>
{% endif %}
{% spaceless %}
<form id="transaction" method="post">
{% csrf_token %}
{{ form }}
</form>
{% endspaceless %}
{% block tables %}
{% if not form.instance.adding %}
<h2>{% translate "Invoices" %}</h2>
{% include "main/table/invoice.html" %}
{% endif %}
{% endwith %}
{% endblock %}

View file

@ -34,10 +34,23 @@ def pmrvalue(val):
@register.filter
def remix(icon):
return mark_safe(f"""<span class="ri-{icon}-line"></span>""")
def remix(icon, cls=""):
return mark_safe(f"""<span class="ri-{icon}-line {cls}"></span>""")
@register.filter
def check(sum, diff):
if sum == diff:
return remix("check", "green")
else:
return remix("close", "red")
@register.filter
def extension(file):
return file.name.split(".")[-1].upper()
@register.filter
def verbose_name(obj):
return obj._meta.verbose_name