Add form for transactions
This commit is contained in:
parent
4ef99f4ef0
commit
5339a725f2
4 changed files with 26 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
|||
from django.shortcuts import render, get_object_or_404
|
||||
from django.shortcuts import render, get_object_or_404, redirect
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
from .models import Transaction, Invoice
|
||||
from .models import Transaction, TransactionForm, Invoice
|
||||
|
||||
|
||||
def index(request):
|
||||
|
@ -21,11 +21,19 @@ def transaction(request, uuid):
|
|||
"main/transaction.html",
|
||||
{
|
||||
"transaction": _transaction,
|
||||
"form": TransactionForm(instance=_transaction),
|
||||
"invoices": _invoices,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def update_transaction(request, uuid):
|
||||
_transaction = get_object_or_404(Transaction, id=uuid)
|
||||
_form = TransactionForm(request.POST, instance=_transaction)
|
||||
_form.save()
|
||||
return redirect(transaction, uuid=uuid)
|
||||
|
||||
|
||||
def invoice(request, uuid):
|
||||
_invoice = get_object_or_404(Invoice, id=uuid)
|
||||
with _invoice.file.open() as _file:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue