From 3ab4eacf9f2fef9ae6cdcd8e344f2ea9403bd026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sat, 4 Mar 2023 07:06:03 +0800 Subject: [PATCH] Moved the "accounting.transaction.template_globals" module to "accounting.template_globals", for the two template globals will be used in the reports beside the transaction management. --- src/accounting/__init__.py | 6 ++++++ src/accounting/{transaction => }/template_globals.py | 0 .../transaction/expense/include/form-currency-item.html | 2 +- .../accounting/transaction/expense/include/form.html | 2 +- .../transaction/income/include/form-currency-item.html | 2 +- .../accounting/transaction/income/include/form.html | 2 +- .../transaction/transfer/include/form-currency-item.html | 2 +- .../accounting/transaction/transfer/include/form.html | 2 +- src/accounting/transaction/dispatcher.py | 2 +- src/accounting/transaction/views.py | 4 ---- 10 files changed, 13 insertions(+), 11 deletions(-) rename src/accounting/{transaction => }/template_globals.py (100%) diff --git a/src/accounting/__init__.py b/src/accounting/__init__.py index c03771f..6f1397c 100644 --- a/src/accounting/__init__.py +++ b/src/accounting/__init__.py @@ -62,6 +62,12 @@ def init_app(app: Flask, user_utils: AbstractUserUtils, bp.add_app_template_filter(format_amount, "accounting_format_amount") bp.add_app_template_filter(format_date, "accounting_format_date") + from .template_globals import currency_options, default_currency_code + bp.add_app_template_global(currency_options, + "accounting_currency_options") + bp.add_app_template_global(default_currency_code, + "accounting_default_currency_code") + from . import locale locale.init_app(app, bp) diff --git a/src/accounting/transaction/template_globals.py b/src/accounting/template_globals.py similarity index 100% rename from src/accounting/transaction/template_globals.py rename to src/accounting/template_globals.py diff --git a/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html b/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html index a355e6c..7187192 100644 --- a/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html +++ b/src/accounting/templates/accounting/transaction/expense/include/form-currency-item.html @@ -25,7 +25,7 @@ First written: 2023/2/25
diff --git a/src/accounting/templates/accounting/transaction/expense/include/form.html b/src/accounting/templates/accounting/transaction/expense/include/form.html index 35b8523..d0ebfda 100644 --- a/src/accounting/templates/accounting/transaction/expense/include/form.html +++ b/src/accounting/templates/accounting/transaction/expense/include/form.html @@ -38,7 +38,7 @@ First written: 2023/2/25 {% else %} {% with currency_index = 1, only_one_currency_form = True, - currency_code_data = accounting_txn_default_currency_code(), + currency_code_data = accounting_default_currency_code(), debit_total = "-" %} {% include "accounting/transaction/expense/include/form-currency-item.html" %} {% endwith %} diff --git a/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html b/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html index 8eeb576..c1d1217 100644 --- a/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html +++ b/src/accounting/templates/accounting/transaction/income/include/form-currency-item.html @@ -25,7 +25,7 @@ First written: 2023/2/25
diff --git a/src/accounting/templates/accounting/transaction/income/include/form.html b/src/accounting/templates/accounting/transaction/income/include/form.html index 285de6a..7761bb0 100644 --- a/src/accounting/templates/accounting/transaction/income/include/form.html +++ b/src/accounting/templates/accounting/transaction/income/include/form.html @@ -38,7 +38,7 @@ First written: 2023/2/25 {% else %} {% with currency_index = 1, only_one_currency_form = True, - currency_code_data = accounting_txn_default_currency_code(), + currency_code_data = accounting_default_currency_code(), credit_total = "-" %} {% include "accounting/transaction/income/include/form-currency-item.html" %} {% endwith %} diff --git a/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html b/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html index 9a8a04e..0278d76 100644 --- a/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html +++ b/src/accounting/templates/accounting/transaction/transfer/include/form-currency-item.html @@ -25,7 +25,7 @@ First written: 2023/2/25
diff --git a/src/accounting/templates/accounting/transaction/transfer/include/form.html b/src/accounting/templates/accounting/transaction/transfer/include/form.html index 3ce7a65..262dc8c 100644 --- a/src/accounting/templates/accounting/transaction/transfer/include/form.html +++ b/src/accounting/templates/accounting/transaction/transfer/include/form.html @@ -41,7 +41,7 @@ First written: 2023/2/25 {% else %} {% with currency_index = 1, only_one_currency_form = True, - currency_code_data = accounting_txn_default_currency_code(), + currency_code_data = accounting_default_currency_code(), debit_total = "-", credit_total = "-" %} {% include "accounting/transaction/transfer/include/form-currency-item.html" %} diff --git a/src/accounting/transaction/dispatcher.py b/src/accounting/transaction/dispatcher.py index 5b6621f..237ff53 100644 --- a/src/accounting/transaction/dispatcher.py +++ b/src/accounting/transaction/dispatcher.py @@ -26,7 +26,7 @@ from flask_wtf import FlaskForm from accounting.models import Transaction from .forms import TransactionForm, IncomeTransactionForm, \ ExpenseTransactionForm, TransferTransactionForm -from .template_globals import default_currency_code +from accounting.template_globals import default_currency_code class TransactionType(ABC): diff --git a/src/accounting/transaction/views.py b/src/accounting/transaction/views.py index 5966334..27831a5 100644 --- a/src/accounting/transaction/views.py +++ b/src/accounting/transaction/views.py @@ -38,7 +38,6 @@ from .forms import sort_transactions_in, TransactionReorderForm from .queries import get_transaction_query from .template_filters import with_type, to_transfer, format_amount_input, \ text2html -from .template_globals import currency_options, default_currency_code bp: Blueprint = Blueprint("transaction", __name__) """The view blueprint for the transaction management.""" @@ -47,9 +46,6 @@ bp.add_app_template_filter(to_transfer, "accounting_txn_to_transfer") bp.add_app_template_filter(format_amount_input, "accounting_txn_format_amount_input") bp.add_app_template_filter(text2html, "accounting_txn_text2html") -bp.add_app_template_global(currency_options, "accounting_txn_currency_options") -bp.add_app_template_global(default_currency_code, - "accounting_txn_default_currency_code") @bp.get("", endpoint="list")