From 6ad4fba9cdf5111c847294ade09fcd90d6e162ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Fri, 10 Mar 2023 09:12:36 +0800 Subject: [PATCH] Moved the "accounting.transaction.operators", "accounting.transaction.summary_editor" and "accounting.transaction.form.account_option" modules into the "accounting.transaction.utils" module. --- .../transaction/form/transaction.py | 4 ++-- src/accounting/transaction/utils/__init__.py | 19 +++++++++++++++++++ .../{form => utils}/account_option.py | 0 .../transaction/{ => utils}/operators.py | 2 +- .../transaction/{ => utils}/summary_editor.py | 0 src/accounting/transaction/views.py | 2 +- tests/test_summary_editor.py | 2 +- 7 files changed, 24 insertions(+), 5 deletions(-) create mode 100644 src/accounting/transaction/utils/__init__.py rename src/accounting/transaction/{form => utils}/account_option.py (100%) rename src/accounting/transaction/{ => utils}/operators.py (99%) rename src/accounting/transaction/{ => utils}/summary_editor.py (100%) diff --git a/src/accounting/transaction/form/transaction.py b/src/accounting/transaction/form/transaction.py index 59ce032..baa398e 100644 --- a/src/accounting/transaction/form/transaction.py +++ b/src/accounting/transaction/form/transaction.py @@ -33,11 +33,11 @@ from accounting import db from accounting.locale import lazy_gettext from accounting.models import Transaction, Account, JournalEntry, \ TransactionCurrency -from accounting.transaction.summary_editor import SummaryEditor +from accounting.transaction.utils.account_option import AccountOption +from accounting.transaction.utils.summary_editor import SummaryEditor from accounting.utils.random_id import new_id from accounting.utils.strip_text import strip_multiline_text from accounting.utils.user import get_current_user_pk -from .account_option import AccountOption from .currency import CurrencyForm, IncomeCurrencyForm, ExpenseCurrencyForm, \ TransferCurrencyForm from .journal_entry import JournalEntryForm, DebitEntryForm, CreditEntryForm diff --git a/src/accounting/transaction/utils/__init__.py b/src/accounting/transaction/utils/__init__.py new file mode 100644 index 0000000..e8f75e2 --- /dev/null +++ b/src/accounting/transaction/utils/__init__.py @@ -0,0 +1,19 @@ +# The Mia! Accounting Flask Project. +# Author: imacat@mail.imacat.idv.tw (imacat), 2023/3/10 + +# Copyright (c) 2023 imacat. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""The utilities for the transaction management. + +""" diff --git a/src/accounting/transaction/form/account_option.py b/src/accounting/transaction/utils/account_option.py similarity index 100% rename from src/accounting/transaction/form/account_option.py rename to src/accounting/transaction/utils/account_option.py diff --git a/src/accounting/transaction/operators.py b/src/accounting/transaction/utils/operators.py similarity index 99% rename from src/accounting/transaction/operators.py rename to src/accounting/transaction/utils/operators.py index c86f047..f8a1678 100644 --- a/src/accounting/transaction/operators.py +++ b/src/accounting/transaction/utils/operators.py @@ -26,7 +26,7 @@ from flask_wtf import FlaskForm from accounting.models import Transaction from accounting.template_globals import default_currency_code from accounting.utils.txn_types import TransactionType -from .form import TransactionForm, IncomeTransactionForm, \ +from accounting.transaction.form import TransactionForm, IncomeTransactionForm, \ ExpenseTransactionForm, TransferTransactionForm diff --git a/src/accounting/transaction/summary_editor.py b/src/accounting/transaction/utils/summary_editor.py similarity index 100% rename from src/accounting/transaction/summary_editor.py rename to src/accounting/transaction/utils/summary_editor.py diff --git a/src/accounting/transaction/views.py b/src/accounting/transaction/views.py index bb0d23e..acf9547 100644 --- a/src/accounting/transaction/views.py +++ b/src/accounting/transaction/views.py @@ -34,9 +34,9 @@ from accounting.utils.permission import has_permission, can_view, can_edit from accounting.utils.txn_types import TransactionType from accounting.utils.user import get_current_user_pk from .form import sort_transactions_in, TransactionReorderForm -from .operators import TransactionOperator, TXN_TYPE_TO_OP, get_txn_op from .template_filters import with_type, to_transfer, format_amount_input, \ text2html +from .utils.operators import TransactionOperator, TXN_TYPE_TO_OP, get_txn_op bp: Blueprint = Blueprint("transaction", __name__) """The view blueprint for the transaction management.""" diff --git a/tests/test_summary_editor.py b/tests/test_summary_editor.py index 35a728c..120d6f2 100644 --- a/tests/test_summary_editor.py +++ b/tests/test_summary_editor.py @@ -66,7 +66,7 @@ class SummeryEditorTestCase(unittest.TestCase): :return: None. """ - from accounting.transaction.summary_editor import SummaryEditor + from accounting.transaction.utils.summary_editor import SummaryEditor for form in get_form_data(self.csrf_token): add_txn(self.client, form) with self.app.app_context():