Renamed the IncomeExpensesAccountConverter path converter to CurrentAccountConverter.

This commit is contained in:
依瑪貓 2023-04-08 07:11:41 +08:00
parent 720e77c814
commit c984d2d596
3 changed files with 8 additions and 9 deletions

View File

@ -27,9 +27,9 @@ def init_app(app: Flask, url_prefix: str) -> None:
:param url_prefix: The URL prefix of the accounting application. :param url_prefix: The URL prefix of the accounting application.
:return: None. :return: None.
""" """
from .converters import PeriodConverter, IncomeExpensesAccountConverter from .converters import PeriodConverter, CurrentAccountConverter
app.url_map.converters["period"] = PeriodConverter app.url_map.converters["period"] = PeriodConverter
app.url_map.converters["ieAccount"] = IncomeExpensesAccountConverter app.url_map.converters["currentAccount"] = CurrentAccountConverter
from .views import bp as report_bp from .views import bp as report_bp
app.register_blueprint(report_bp, url_prefix=url_prefix) app.register_blueprint(report_bp, url_prefix=url_prefix)

View File

@ -51,9 +51,9 @@ class PeriodConverter(BaseConverter):
return value.spec return value.spec
class IncomeExpensesAccountConverter(BaseConverter): class CurrentAccountConverter(BaseConverter):
"""The converter to convert the income and expenses log account code from """The converter to convert the current account code from and to the
and to the corresponding account in the routes.""" corresponding account in the routes."""
def to_python(self, value: str) -> CurrentAccount: def to_python(self, value: str) -> CurrentAccount:
"""Converts an account code to an account. """Converts an account code to an account.

View File

@ -125,7 +125,7 @@ def __get_ledger(currency: Currency, account: Account, period: Period) \
return report.html() return report.html()
@bp.get("income-expenses/<currency:currency>/<ieAccount:account>", @bp.get("income-expenses/<currency:currency>/<currentAccount:account>",
endpoint="income-expenses-default") endpoint="income-expenses-default")
@has_permission(can_view) @has_permission(can_view)
def get_default_income_expenses(currency: Currency, account: CurrentAccount) \ def get_default_income_expenses(currency: Currency, account: CurrentAccount) \
@ -139,9 +139,8 @@ def get_default_income_expenses(currency: Currency, account: CurrentAccount) \
return __get_income_expenses(currency, account, get_period()) return __get_income_expenses(currency, account, get_period())
@bp.get( @bp.get("income-expenses/<currency:currency>/<currentAccount:account>/"
"income-expenses/<currency:currency>/<ieAccount:account>/<period:period>", "<period:period>", endpoint="income-expenses")
endpoint="income-expenses")
@has_permission(can_view) @has_permission(can_view)
def get_income_expenses(currency: Currency, account: CurrentAccount, def get_income_expenses(currency: Currency, account: CurrentAccount,
period: Period) -> str | Response: period: Period) -> str | Response: