From de09e1498befab27102b635e0423bdbe1fc030df 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 08:34:11 +0800 Subject: [PATCH] Added the __get_default_page_uri() function to the "accounting.transaction.views" module to simplify the code. --- src/accounting/transaction/views.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/accounting/transaction/views.py b/src/accounting/transaction/views.py index 8b32c90..0543285 100644 --- a/src/accounting/transaction/views.py +++ b/src/accounting/transaction/views.py @@ -163,7 +163,7 @@ def delete_transaction(txn: Transaction) -> redirect: sort_transactions_in(txn.date, txn.id) db.session.commit() flash(lazy_gettext("The transaction is deleted successfully."), "success") - return redirect(or_next(url_for("accounting.report.default"))) + return redirect(or_next(__get_default_page_uri())) @bp.get("/dates/", endpoint="order") @@ -194,10 +194,10 @@ def sort_transactions(txn_date: date) -> redirect: form.save_order() if not form.is_modified: flash(lazy_gettext("The order was not modified."), "success") - return redirect(or_next(url_for("accounting.report.default"))) + return redirect(or_next(__get_default_page_uri())) db.session.commit() flash(lazy_gettext("The order is updated successfully."), "success") - return redirect(or_next(url_for("accounting.report.default"))) + return redirect(or_next(__get_default_page_uri())) def __get_detail_uri(txn: Transaction) -> str: @@ -207,3 +207,11 @@ def __get_detail_uri(txn: Transaction) -> str: :return: The detail URI of the transaction. """ return url_for("accounting.transaction.detail", txn=txn) + + +def __get_default_page_uri() -> str: + """Returns the URI for the default page. + + :return: The URI for the default page. + """ + return url_for("accounting.report.default")