From 4561fa4b399c89c41a79925749055002fa6276bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=9D=E7=91=AA=E8=B2=93?= Date: Sun, 2 Aug 2020 10:01:17 +0800 Subject: [PATCH] dded to return as "not modified" when the transaction was not modified in the accounting application. --- accounting/views.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/accounting/views.py b/accounting/views.py index aaf0352..9fcbdea 100644 --- a/accounting/views.py +++ b/accounting/views.py @@ -858,19 +858,19 @@ def txn_store(request, txn_type, txn=None): if txn is None: url = reverse("accounting:transactions.create", args=(txn_type,)) else: - url = reverse( - "accounting:transactions.edit", args=(txn_type, txn)) - return error_redirect( - request, - str(UrlBuilder(url).set("r", request.GET.get("r"))), - post) + url = reverse("accounting:transactions.edit", args=(txn_type, txn)) + url = str(UrlBuilder(url).set("r", request.GET.get("r"))) + return error_redirect(request, url, post) if txn is None: txn = Transaction() fill_txn_from_post(txn, post) + if not txn.is_dirty(): + url = reverse("accounting:transactions.show", args=(txn_type, txn)) + url = str(UrlBuilder(url).set("r", request.GET.get("r"))) + message = gettext_noop("This transaction was not modified.") + return success_redirect(request, url, message) # TODO: Stores the data - return success_redirect( - request, - str(UrlBuilder(reverse("accounting:transactions.show", - args=(txn_type, txn))) - .add("r", request.GET.get("r"))), - gettext_noop("This transaction was saved successfully.")) + url = reverse("accounting:transactions.show", args=(txn_type, txn)) + url = str(UrlBuilder(url).set("r", request.GET.get("r"))) + message = gettext_noop("This transaction was saved successfully.") + return success_redirect(request, url, message)