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.
:return: None.
"""
from .converters import PeriodConverter, IncomeExpensesAccountConverter
from .converters import PeriodConverter, CurrentAccountConverter
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
app.register_blueprint(report_bp, url_prefix=url_prefix)

View File

@ -51,9 +51,9 @@ class PeriodConverter(BaseConverter):
return value.spec
class IncomeExpensesAccountConverter(BaseConverter):
"""The converter to convert the income and expenses log account code from
and to the corresponding account in the routes."""
class CurrentAccountConverter(BaseConverter):
"""The converter to convert the current account code from and to the
corresponding account in the routes."""
def to_python(self, value: str) -> CurrentAccount:
"""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()
@bp.get("income-expenses/<currency:currency>/<ieAccount:account>",
@bp.get("income-expenses/<currency:currency>/<currentAccount:account>",
endpoint="income-expenses-default")
@has_permission(can_view)
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())
@bp.get(
"income-expenses/<currency:currency>/<ieAccount:account>/<period:period>",
endpoint="income-expenses")
@bp.get("income-expenses/<currency:currency>/<currentAccount:account>/"
"<period:period>", endpoint="income-expenses")
@has_permission(can_view)
def get_income_expenses(currency: Currency, account: CurrentAccount,
period: Period) -> str | Response: