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

View file

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

View file

@ -1,40 +1,16 @@
{% extends "main/base.html" %} {% extends "main/form/base.html" %}
{% load static %}
{% load main_extras %} {% load main_extras %}
{% load i18n %} {% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %} {% block h1 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block link %} {% block tables %}
{{ block.super }} {% if not form.instance.adding %}
<link rel="stylesheet" <h2>{% translate "Statements" %}</h2>
href="{% static 'main/css/form.css' %}" {% include "main/table/snapshot.html" %}
type="text/css" /> {% endif %}
<link rel="stylesheet" {% if transactions %}
href="{% static 'main/css/table.css' %}" <h2>{% translate "Transactions" %}</h2>
type="text/css" /> {% include "main/table/transaction.html" %}
<link rel="stylesheet" <h2>{% translate "History" %}</h2>
href="{% static 'main/css/plot.css' %}" {% include "main/plot/history.html" %}
type="text/css" /> {% endif %}
{% 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 %}
<h2>{% translate "Statements" %}</h2>
{% include "main/table/snapshot.html" %}
{% endif %}
{% if transactions %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
<h2>{% translate "History" %}</h2>
{% include "main/plot/history.html" %}
{% endif %}
{% endwith %}
{% endblock %} {% 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" %} {% extends "main/form/base.html" %}
{% load static %}
{% load main_extras %} {% load main_extras %}
{% load i18n %} {% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %} {% block h1 %}{{ form.instance.icon|remix }}{{ form.instance }}{% endblock %}
{% block link %} {% block tables %}
{{ block.super }} {% if form.instance.transactions %}
<link rel="stylesheet" <h2>{% translate "Transactions" %}</h2>
href="{% static 'main/css/form.css' %}" {% include "main/table/transaction.html" %}
type="text/css" /> <h2>{% translate "History" %}</h2>
<link rel="stylesheet" {% include "main/plot/history.html" %}
href="{% static 'main/css/table.css' %}" {% endif %}
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 %}
<h2>{% translate "Transactions" %}</h2>
{% include "main/table/transaction.html" %}
<h2>{% translate "History" %}</h2>
{% include "main/plot/history.html" %}
{% endif %}
{% endwith %}
{% endblock %} {% endblock %}

View file

@ -1,32 +1 @@
{% extends "main/base.html" %} {% extends "main/form/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 %}

View file

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

View file

@ -1,33 +1,8 @@
{% extends "main/base.html" %} {% extends "main/form/base.html" %}
{% load static %}
{% load main_extras %}
{% load i18n %} {% load i18n %}
{% block title %}{{ form.instance }} Nummi{% endblock %} {% block tables %}
{% block link %} {% if not form.instance.adding %}
{{ block.super }} <h2>{% translate "Invoices" %}</h2>
<link rel="stylesheet" {% include "main/table/invoice.html" %}
href="{% static 'main/css/form.css' %}" {% endif %}
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 %}
{% if not form.instance.adding %}
<h2>{% translate "Invoices" %}</h2>
{% include "main/table/invoice.html" %}
{% endif %}
{% endwith %}
{% endblock %} {% endblock %}

View file

@ -34,10 +34,23 @@ def pmrvalue(val):
@register.filter @register.filter
def remix(icon): def remix(icon, cls=""):
return mark_safe(f"""<span class="ri-{icon}-line"></span>""") 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 @register.filter
def extension(file): def extension(file):
return file.name.split(".")[-1].upper() return file.name.split(".")[-1].upper()
@register.filter
def verbose_name(obj):
return obj._meta.verbose_name