Added get_success_url() to TransactionSortFormView to utilize the namespace in the accounting application.

This commit is contained in:
依瑪貓 2020-08-17 22:44:43 +08:00
parent c400d65f91
commit d1cb5cb0d0

View File

@ -922,8 +922,13 @@ class TransactionSortFormView(FormView):
Transaction.objects.filter(pk=x.txn.pk).update(ord=x.order) Transaction.objects.filter(pk=x.txn.pk).update(ord=x.order)
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.request.GET.get("r") return redirect(self.get_success_url())
or reverse("accounting:home"))
def get_success_url(self) -> str:
"""Returns the URL on success."""
return self.request.GET.get("r")\
or reverse("accounting:home",
current_app=self.request.resolver_match.namespace)
@method_decorator(require_GET, name="dispatch") @method_decorator(require_GET, name="dispatch")