From 24eeb54a6b7159964e8887ade7fa5173b50feb3a Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 26 Jan 2025 17:58:57 +0100 Subject: Replace tera by minijinja tera was doing the job all right, but minijinja has fewer dependencies. --- templates/balance.html | 14 +++++++------- templates/base.html | 6 +++--- templates/category/create.html | 4 ++-- templates/category/update.html | 4 ++-- templates/income/create.html | 12 ++++++------ templates/income/table.html | 6 +++--- templates/income/update.html | 10 +++++----- templates/macros/paging.html | 16 +++++----------- templates/payment/create.html | 12 ++++++------ templates/payment/table.html | 8 ++++---- templates/payment/table/search.html | 8 ++++---- templates/payment/update.html | 10 +++++----- templates/report/list.j2 | 6 +++--- templates/report/report.j2 | 26 +++++++++++++------------- templates/statistics.html | 2 +- 15 files changed, 69 insertions(+), 75 deletions(-) (limited to 'templates') diff --git a/templates/balance.html b/templates/balance.html index b97ea40..c7f68e8 100644 --- a/templates/balance.html +++ b/templates/balance.html @@ -11,7 +11,7 @@ @@ -35,14 +35,14 @@ {% for user_income in user_incomes %}
- {{ user_income.0 }} + {{ user_income[0] }} - {{ user_income.1 | euros() }} + {{ user_income[1] | euros() }} {% if total_income > 0 %} - {{ user_income.1 / total_income * 100 | round() }} % + {{ (user_income[1] / total_income * 100) | round }} % {% else %} – {% endif %} @@ -76,14 +76,14 @@ {% for user_payment in user_payments %}
- {{ user_payment.0 }} + {{ user_payment[0] }} - {{ user_payment.1 | euros() }} + {{ user_payment[1] | euros() }} {% if total_payments > 0 %} - {{ user_payment.1 / total_payments * 100 | round() }} % + {{ (user_payment[1] / total_payments * 100) | round }} % {% else %} – {% endif %} diff --git a/templates/base.html b/templates/base.html index c7dc9f0..9865e16 100644 --- a/templates/base.html +++ b/templates/base.html @@ -4,8 +4,8 @@ Budget — {% block title %}{% endblock title %} - - + + {% if connected_user %}
@@ -78,5 +78,5 @@ {% block main %}{% endblock main %} - diff --git a/templates/category/create.html b/templates/category/create.html index af95e16..f5395bf 100644 --- a/templates/category/create.html +++ b/templates/category/create.html @@ -27,7 +27,7 @@ @@ -39,7 +39,7 @@ name="color" type="color" class="g-Form__Input g-Form__InputColor" - value="{{ form.color | default(value="") }}" + value="{{ form.color or "" }}" required /> diff --git a/templates/category/update.html b/templates/category/update.html index 48dda06..544c583 100644 --- a/templates/category/update.html +++ b/templates/category/update.html @@ -35,7 +35,7 @@ @@ -46,7 +46,7 @@ name="color" type="color" class="g-Form__Input g-Form__InputColor" - value="{{ form.color | default(value=category.color) }}" + value="{{ form.color or category.color }}" required /> diff --git a/templates/income/create.html b/templates/income/create.html index 3c899ca..a7755db 100644 --- a/templates/income/create.html +++ b/templates/income/create.html @@ -10,7 +10,7 @@

Retour aux revenus @@ -18,7 +18,7 @@

@@ -35,13 +35,13 @@ name="amount" type="number" class="g-Form__Input" - value="{{ form.amount | default(value="") }}" + value="{{ form.amount or "" }}" required {% if not form %} autofocus {% endif %} /> - {% set user_id = form.user_id | default(value="" ~ connected_user.id) %} + {% set user_id = form.user_id or connected_user.id %} - {% set month_index = form.month | default(value="" ~ current_month) %} + {% set month_index = form.month or current_month %} diff --git a/templates/income/table.html b/templates/income/table.html index 60cd6e0..34ee096 100644 --- a/templates/income/table.html +++ b/templates/income/table.html @@ -18,7 +18,7 @@ Ajouter un revenu @@ -33,7 +33,7 @@ {% for income in incomes %} {{ income.amount | euros() }} @@ -44,7 +44,7 @@ {% endfor %}

- {{ paging::paging( + {{ paging.view( url="/incomes", page=page, max_page=max_page diff --git a/templates/income/update.html b/templates/income/update.html index 855d5c4..f5f976e 100644 --- a/templates/income/update.html +++ b/templates/income/update.html @@ -10,7 +10,7 @@

Retour aux revenus @@ -39,12 +39,12 @@ name="amount" type="number" class="g-Form__Input" - value="{{ form.amount | default(value=income.amount) }}" + value="{{ form.amount or income.amount }}" required /> - {% set user_id = form.user_id | default(value="" ~ income.user_id) %} + {% set user_id = form.user_id or income.user_id %} - {% set month_index = form.month | default(value="" ~ income.month) %} + {% set month_index = form.month or income.month %} diff --git a/templates/macros/paging.html b/templates/macros/paging.html index 59ba617..840e8f4 100644 --- a/templates/macros/paging.html +++ b/templates/macros/paging.html @@ -1,10 +1,4 @@ -{% macro paging(url, page, max_page) %} - {% if url is containing("?") %} - {% set sign = "&" %} - {% else %} - {% set sign = "?" %} - {% endif %} - +{% macro view(url, page, max_page) %}

{% if page > 1 %} @@ -33,13 +27,13 @@ {% if page < max_page %} ❭❭ @@ -52,4 +46,4 @@ {% endif %}
-{% endmacro paging %} +{% endmacro %} diff --git a/templates/payment/create.html b/templates/payment/create.html index 4ac73de..7bcc536 100644 --- a/templates/payment/create.html +++ b/templates/payment/create.html @@ -44,7 +44,7 @@ @@ -56,12 +56,12 @@ name="cost" type="number" class="g-Form__Input" - value="{{ form.cost | default(value="") }}" + value="{{ form.cost or "" }}" required /> - {% set user_id = form.user_id | default(value="" ~ connected_user.id) %} + {% set user_id = form.user_id or connected_user.id %} - {% set category_id = form.category_id | default(value="") %} + {% set category_id = form.category_id or "" %} - {% set date = form.date | default(value=now() | date(format="%Y-%m-%d")) %} + {% set date = form.date or now("%Y-%m-%d") %} {% if query.frequency != "Monthly" %}
{{ payment.user }} - {{ payment.category_name }} @@ -97,7 +97,7 @@ {% endfor %}
- {{ paging::paging( + {{ paging.view( url="/" ~ payments_params( frequency=query.frequency, name=query.name, diff --git a/templates/payment/table/search.html b/templates/payment/table/search.html index 9fedb78..cb72282 100644 --- a/templates/payment/table/search.html +++ b/templates/payment/table/search.html @@ -17,7 +17,7 @@ type="search" name="name" class="g-Form__Input" - value="{{ query.name }}" + value="{{ query.name or '' }}" /> @@ -27,7 +27,7 @@ type="number" name="cost" class="g-Form__Input" - value="{{ query.cost }}" + value="{{ query.cost or '' }}" /> @@ -67,7 +67,7 @@ type="date" name="start_date" class="g-Form__Input" - value="{{ query.start_date }}" + value="{{ query.start_date or '' }}" /> @@ -77,7 +77,7 @@ type="date" name="end_date" class="g-Form__Input" - value="{{ query.end_date }}" + value="{{ query.end_date or '' }}" /> diff --git a/templates/payment/update.html b/templates/payment/update.html index 22a4d01..dfa0892 100644 --- a/templates/payment/update.html +++ b/templates/payment/update.html @@ -57,7 +57,7 @@ @@ -68,12 +68,12 @@ name="cost" type="number" class="g-Form__Input" - value="{{ form.cost | default(value=payment.cost) }}" + value="{{ form.cost or payment.cost }}" required /> - {% set user_id = form.user_id | default(value="" ~ payment.user_id) %} + {% set user_id = form.user_id or payment.user_id %} - {% set category_id = form.category_id | default(value="" ~ payment.category_id) %} + {% set category_id = form.category_id or payment.category_id %} - {% set date = form.date | default(value=payment.date) %} + {% set date = form.date or payment.date %} {% if payment.frequency == "Punctual" %}