mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-07-08 13:55:21 +02:00
feat: add transfer form
This commit is contained in:
@@ -13,7 +13,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from unicodedata import category
|
||||
|
||||
from apps.transactions.forms import TransactionForm
|
||||
from apps.transactions.forms import TransactionForm, TransferForm
|
||||
from apps.transactions.models import Transaction
|
||||
|
||||
|
||||
@@ -170,6 +170,23 @@ def transaction_delete(request, transaction_id, **kwargs):
|
||||
)
|
||||
|
||||
|
||||
@login_required
|
||||
def transactions_transfer(request):
|
||||
if request.method == "POST":
|
||||
form = TransferForm(request.POST)
|
||||
if form.is_valid():
|
||||
from_transaction, to_transaction = form.save()
|
||||
messages.success(request, "Transfer completed successfully.")
|
||||
return HttpResponse(
|
||||
status=204,
|
||||
headers={"HX-Trigger": "transaction_updated, toast"},
|
||||
)
|
||||
else:
|
||||
form = TransferForm()
|
||||
|
||||
return render(request, "transactions/fragments/transfer.html", {"form": form})
|
||||
|
||||
|
||||
@login_required
|
||||
def transaction_pay(request, transaction_id):
|
||||
transaction = get_object_or_404(Transaction, pk=transaction_id)
|
||||
|
||||
Reference in New Issue
Block a user