Applied the standardized control flow to the txn_sort view in the accounting application.

This commit is contained in:
依瑪貓 2020-08-12 22:47:55 +08:00
parent 45dded8c2d
commit c8c276feb7

View File

@ -944,15 +944,14 @@ def txn_sort(request, date):
if x.ord != post[F"transaction-{x.pk}-ord"]] if x.ord != post[F"transaction-{x.pk}-ord"]]
if len(modified) == 0: if len(modified) == 0:
messages.success(request, gettext_noop( message = gettext_noop("The transaction orders were not modified.")
"The transaction orders were not modified.")) else:
return redirect(request.GET.get("r") or reverse("accounting:home"))
with transaction.atomic(): with transaction.atomic():
for x in modified: for x in modified:
Transaction.objects.filter(pk=x[0].pk).update(ord=x[1]) Transaction.objects.filter(pk=x[0].pk).update(ord=x[1])
messages.success(request, gettext_noop( message = gettext_noop(
"The transaction orders were saved successfully.")) "The transaction orders were saved successfully.")
messages.success(request, message)
return redirect(request.GET.get("r") or reverse("accounting:home")) return redirect(request.GET.get("r") or reverse("accounting:home"))