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():
for x in modified:
with transaction.atomic(): Transaction.objects.filter(pk=x[0].pk).update(ord=x[1])
for x in modified: message = gettext_noop(
Transaction.objects.filter(pk=x[0].pk).update(ord=x[1]) "The transaction orders were saved successfully.")
messages.success(request, gettext_noop( messages.success(request, message)
"The transaction orders were saved successfully."))
return redirect(request.GET.get("r") or reverse("accounting:home")) return redirect(request.GET.get("r") or reverse("accounting:home"))