Renamed the TransactionType class to TransactionOperator.
This commit is contained in:
src/accounting/transaction
@ -34,7 +34,7 @@ from accounting.utils.pagination import Pagination
|
||||
from accounting.utils.permission import has_permission, can_view, can_edit
|
||||
from accounting.utils.txn_types import TransactionTypeEnum
|
||||
from accounting.utils.user import get_current_user_pk
|
||||
from .dispatcher import TransactionType, TXN_ENUM_TO_OP, get_txn_type_op
|
||||
from .dispatcher import TransactionOperator, TXN_ENUM_TO_OP, get_txn_op
|
||||
from .forms import sort_transactions_in, TransactionReorderForm
|
||||
from .queries import get_transaction_query
|
||||
from .template_filters import with_type, to_transfer, format_amount_input, \
|
||||
@ -71,15 +71,15 @@ def show_add_transaction_form(txn_type: TransactionTypeEnum) -> str:
|
||||
:param txn_type: The transaction type.
|
||||
:return: The form to add a transaction.
|
||||
"""
|
||||
txn_type_op: TransactionType = TXN_ENUM_TO_OP[txn_type]
|
||||
form: txn_type_op.form
|
||||
txn_op: TransactionOperator = TXN_ENUM_TO_OP[txn_type]
|
||||
form: txn_op.form
|
||||
if "form" in session:
|
||||
form = txn_type_op.form(ImmutableMultiDict(parse_qsl(session["form"])))
|
||||
form = txn_op.form(ImmutableMultiDict(parse_qsl(session["form"])))
|
||||
del session["form"]
|
||||
form.validate()
|
||||
else:
|
||||
form = txn_type_op.form()
|
||||
return txn_type_op.render_create_template(form)
|
||||
form = txn_op.form()
|
||||
return txn_op.render_create_template(form)
|
||||
|
||||
|
||||
@bp.post("/store/<transactionType:txn_type>", endpoint="store")
|
||||
@ -91,8 +91,8 @@ def add_transaction(txn_type: TransactionTypeEnum) -> redirect:
|
||||
:return: The redirection to the transaction detail on success, or the
|
||||
transaction creation form on error.
|
||||
"""
|
||||
txn_type_op: TransactionType = TXN_ENUM_TO_OP[txn_type]
|
||||
form: txn_type_op.form = txn_type_op.form(request.form)
|
||||
txn_op: TransactionOperator = TXN_ENUM_TO_OP[txn_type]
|
||||
form: txn_op.form = txn_op.form(request.form)
|
||||
if not form.validate():
|
||||
flash_form_errors(form)
|
||||
session["form"] = urlencode(list(request.form.items()))
|
||||
@ -114,8 +114,8 @@ def show_transaction_detail(txn: Transaction) -> str:
|
||||
:param txn: The transaction.
|
||||
:return: The detail.
|
||||
"""
|
||||
txn_type_op: TransactionType = get_txn_type_op(txn)
|
||||
return txn_type_op.render_detail_template(txn)
|
||||
txn_op: TransactionOperator = get_txn_op(txn)
|
||||
return txn_op.render_detail_template(txn)
|
||||
|
||||
|
||||
@bp.get("/<transaction:txn>/edit", endpoint="edit")
|
||||
@ -126,15 +126,15 @@ def show_transaction_edit_form(txn: Transaction) -> str:
|
||||
:param txn: The transaction.
|
||||
:return: The form to edit the transaction.
|
||||
"""
|
||||
txn_type_op: TransactionType = get_txn_type_op(txn)
|
||||
form: txn_type_op.form
|
||||
txn_op: TransactionOperator = get_txn_op(txn)
|
||||
form: txn_op.form
|
||||
if "form" in session:
|
||||
form = txn_type_op.form(ImmutableMultiDict(parse_qsl(session["form"])))
|
||||
form = txn_op.form(ImmutableMultiDict(parse_qsl(session["form"])))
|
||||
del session["form"]
|
||||
form.validate()
|
||||
else:
|
||||
form = txn_type_op.form(obj=txn)
|
||||
return txn_type_op.render_edit_template(txn, form)
|
||||
form = txn_op.form(obj=txn)
|
||||
return txn_op.render_edit_template(txn, form)
|
||||
|
||||
|
||||
@bp.post("/<transaction:txn>/update", endpoint="update")
|
||||
@ -146,8 +146,8 @@ def update_transaction(txn: Transaction) -> redirect:
|
||||
:return: The redirection to the transaction detail on success, or the
|
||||
transaction edit form on error.
|
||||
"""
|
||||
txn_type_op: TransactionType = get_txn_type_op(txn)
|
||||
form: txn_type_op.form = txn_type_op.form(request.form)
|
||||
txn_op: TransactionOperator = get_txn_op(txn)
|
||||
form: txn_op.form = txn_op.form(request.form)
|
||||
if not form.validate():
|
||||
flash_form_errors(form)
|
||||
session["form"] = urlencode(list(request.form.items()))
|
||||
|
Reference in New Issue
Block a user