Homepage, transaction page and invoice
This commit is contained in:
parent
a0f4e5ae54
commit
08868ce7c6
7 changed files with 50 additions and 4 deletions
|
@ -1,6 +1,32 @@
|
|||
from django.shortcuts import render
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
from django.http import HttpResponse
|
||||
|
||||
|
||||
from .models import Transaction, Invoice
|
||||
|
||||
|
||||
def index(request):
|
||||
return HttpResponse("Hello world!")
|
||||
_transactions = Transaction.objects.order_by("date")[:5]
|
||||
context = {
|
||||
"transactions": _transactions,
|
||||
}
|
||||
return render(request, "main/index.html", context)
|
||||
|
||||
|
||||
def transaction(request, uuid):
|
||||
_transaction = get_object_or_404(Transaction, id=uuid)
|
||||
_invoices = Invoice.objects.filter(transaction=_transaction)
|
||||
return render(
|
||||
request,
|
||||
"main/transaction.html",
|
||||
{
|
||||
"transaction": _transaction,
|
||||
"invoices": _invoices,
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def invoice(request, uuid):
|
||||
_invoice = get_object_or_404(Invoice, id=uuid)
|
||||
with _invoice.file.open() as _file:
|
||||
return HttpResponse(_file.read(), content_type="application/pdf")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue