From 9248ba7e3be8ce9772387f79eca58ae46d98f9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Tue, 21 Mar 2023 21:17:10 +0800 Subject: [PATCH] Removed the redundant Flask App context from the default_currency_code Jinja2 global and the default_ie_account_code function. They are always under the Flask app context. --- src/accounting/report/utils/ie_account.py | 5 ++--- src/accounting/template_globals.py | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/accounting/report/utils/ie_account.py b/src/accounting/report/utils/ie_account.py index 96c84fd..cb37dc8 100644 --- a/src/accounting/report/utils/ie_account.py +++ b/src/accounting/report/utils/ie_account.py @@ -71,9 +71,8 @@ def default_ie_account_code() -> str: :return: The default account code for the income and expenses log. """ - with current_app.app_context(): - return current_app.config.get("ACCOUNTING_DEFAULT_IE_ACCOUNT", - Account.CASH_CODE) + return current_app.config.get("ACCOUNTING_DEFAULT_IE_ACCOUNT", + Account.CASH_CODE) def default_ie_account() -> IncomeExpensesAccount: diff --git a/src/accounting/template_globals.py b/src/accounting/template_globals.py index b4d69be..b43d3c0 100644 --- a/src/accounting/template_globals.py +++ b/src/accounting/template_globals.py @@ -35,5 +35,4 @@ def default_currency_code() -> str: :return: The default currency code. """ - with current_app.app_context(): - return current_app.config.get("ACCOUNTING_DEFAULT_CURRENCY", "USD") + return current_app.config.get("ACCOUNTING_DEFAULT_CURRENCY", "USD")