Renamed the "order" property to "ord" in the TransactionSortForm.Order class.
This commit is contained in:
parent
3d4d20614c
commit
1c44d51e92
@ -479,7 +479,7 @@ class TransactionSortForm(forms.Form):
|
|||||||
post_orders.append(form.Order(txn, 9999))
|
post_orders.append(form.Order(txn, 9999))
|
||||||
else:
|
else:
|
||||||
post_orders.append(form.Order(txn, int(post[key])))
|
post_orders.append(form.Order(txn, int(post[key])))
|
||||||
post_orders.sort(key=lambda x: (x.order, x.txn.ord))
|
post_orders.sort(key=lambda x: (x.ord, x.txn.ord))
|
||||||
form.txn_orders = []
|
form.txn_orders = []
|
||||||
for i in range(len(post_orders)):
|
for i in range(len(post_orders)):
|
||||||
form.txn_orders.append(form.Order(post_orders[i].txn, i + 1))
|
form.txn_orders.append(form.Order(post_orders[i].txn, i + 1))
|
||||||
@ -488,9 +488,9 @@ class TransactionSortForm(forms.Form):
|
|||||||
|
|
||||||
class Order:
|
class Order:
|
||||||
"""A transaction order"""
|
"""A transaction order"""
|
||||||
def __init__(self, txn: Transaction, order: int):
|
def __init__(self, txn: Transaction, ord: int):
|
||||||
self.txn = txn
|
self.txn = txn
|
||||||
self.order = order
|
self.ord = ord
|
||||||
|
|
||||||
|
|
||||||
class AccountForm(forms.Form):
|
class AccountForm(forms.Form):
|
||||||
|
@ -1086,13 +1086,13 @@ class TransactionSortFormView(FormView):
|
|||||||
|
|
||||||
def form_valid(self, form: TransactionSortForm) -> HttpResponseRedirect:
|
def form_valid(self, form: TransactionSortForm) -> HttpResponseRedirect:
|
||||||
"""Handles the action when the POST form is valid."""
|
"""Handles the action when the POST form is valid."""
|
||||||
modified = [x for x in form.txn_orders if x.txn.ord != x.order]
|
modified = [x for x in form.txn_orders if x.txn.ord != x.ord]
|
||||||
if len(modified) == 0:
|
if len(modified) == 0:
|
||||||
message = self.get_not_modified_message(form.cleaned_data)
|
message = self.get_not_modified_message(form.cleaned_data)
|
||||||
else:
|
else:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for x in modified:
|
for x in modified:
|
||||||
Transaction.objects.filter(pk=x.txn.pk).update(ord=x.order)
|
Transaction.objects.filter(pk=x.txn.pk).update(ord=x.ord)
|
||||||
message = self.get_success_message(form.cleaned_data)
|
message = self.get_success_message(form.cleaned_data)
|
||||||
messages.success(self.request, message)
|
messages.success(self.request, message)
|
||||||
return redirect(self.get_success_url())
|
return redirect(self.get_success_url())
|
||||||
|
Loading…
Reference in New Issue
Block a user