Renamed "sorting" to "reorder", and the "sort-form" route to "order".
This commit is contained in:
@ -131,11 +131,11 @@ def sort_accounts_in(base_code: str, exclude: int) -> None:
|
||||
accounts[i].no = i + 1
|
||||
|
||||
|
||||
class AccountSortForm:
|
||||
"""The form to sort the accounts."""
|
||||
class AccountReorderForm:
|
||||
"""The form to reorder the accounts."""
|
||||
|
||||
def __init__(self, base: BaseAccount):
|
||||
"""Constructs the form to sort the accounts under a base account.
|
||||
"""Constructs the form to reorder the accounts under a base account.
|
||||
|
||||
:param base: The base account.
|
||||
"""
|
||||
|
@ -29,7 +29,7 @@ from accounting.models import Account, BaseAccount
|
||||
from accounting.utils.next_url import inherit_next, or_next
|
||||
from accounting.utils.pagination import Pagination
|
||||
from accounting.utils.permission import can_view, has_permission, can_edit
|
||||
from .forms import AccountForm, sort_accounts_in, AccountSortForm
|
||||
from .forms import AccountForm, sort_accounts_in, AccountReorderForm
|
||||
|
||||
bp: Blueprint = Blueprint("account", __name__)
|
||||
"""The view blueprint for the account management."""
|
||||
@ -168,28 +168,27 @@ def delete_account(account: Account) -> redirect:
|
||||
return redirect(or_next(url_for("accounting.account.list")))
|
||||
|
||||
|
||||
@bp.get("/sort/<baseAccount:base>", endpoint="sort-form")
|
||||
@bp.get("/base/<baseAccount:base>", endpoint="order")
|
||||
@has_permission(can_edit)
|
||||
def show_sort_form(base: BaseAccount) -> str:
|
||||
"""Shows the form to sort the accounts under a base account.
|
||||
def show_account_order(base: BaseAccount) -> str:
|
||||
"""Shows the order of the accounts under a same base account.
|
||||
|
||||
:param base: The base account.
|
||||
:return: The form to sort the accounts under the base account.
|
||||
:return: The order of the accounts under the base account.
|
||||
"""
|
||||
return render_template("accounting/account/sort.html",
|
||||
base=base)
|
||||
return render_template("accounting/account/order.html", base=base)
|
||||
|
||||
|
||||
@bp.post("/sort/<baseAccount:base>", endpoint="sort")
|
||||
@bp.post("/base/<baseAccount:base>", endpoint="sort")
|
||||
@has_permission(can_edit)
|
||||
def sort_accounts(base: BaseAccount) -> redirect:
|
||||
"""Sorts the accounts under a base account.
|
||||
"""Reorders the accounts under a base account.
|
||||
|
||||
:param base: The base account.
|
||||
:return: The redirection to the incoming account or the account list. The
|
||||
sorting operation does not fail.
|
||||
reordering operation does not fail.
|
||||
"""
|
||||
form: AccountSortForm = AccountSortForm(base)
|
||||
form: AccountReorderForm = AccountReorderForm(base)
|
||||
form.save_order()
|
||||
if not form.is_modified:
|
||||
flash(lazy_gettext("The order was not modified."), "success")
|
||||
|
Reference in New Issue
Block a user