Homepage, transaction page and invoice
This commit is contained in:
parent
a0f4e5ae54
commit
08868ce7c6
7 changed files with 50 additions and 4 deletions
BIN
nummi/invoices/01_UtilisationENG.pdf
Normal file
BIN
nummi/invoices/01_UtilisationENG.pdf
Normal file
Binary file not shown.
BIN
nummi/invoices/artha.jpg
Normal file
BIN
nummi/invoices/artha.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 481 KiB |
|
@ -1,3 +1,6 @@
|
|||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
from .models import Transaction, Invoice
|
||||
|
||||
admin.site.register(Transaction)
|
||||
admin.site.register(Invoice)
|
||||
|
|
7
nummi/main/templates/main/index.html
Normal file
7
nummi/main/templates/main/index.html
Normal file
|
@ -0,0 +1,7 @@
|
|||
{% if transactions %}
|
||||
<ul>
|
||||
{% for trans in transactions %}
|
||||
<li><a href="transaction/{{ trans.id }}">{{ trans }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
6
nummi/main/templates/main/transaction.html
Normal file
6
nummi/main/templates/main/transaction.html
Normal file
|
@ -0,0 +1,6 @@
|
|||
<h1>{{ transaction }}</h1>
|
||||
<ul>
|
||||
{% for inv in invoices %}
|
||||
<li><a href="../invoice/{{ inv.id }}">{{ inv.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
|
@ -2,4 +2,8 @@ from django.urls import path
|
|||
|
||||
from . import views
|
||||
|
||||
urlpatterns = [path("", views.index, name="index")]
|
||||
urlpatterns = [
|
||||
path("", views.index, name="index"),
|
||||
path("transaction/<uuid>", views.transaction, name="transaction"),
|
||||
path("invoice/<uuid>", views.invoice, name="invoice"),
|
||||
]
|
||||
|
|
|
@ -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…
Reference in a new issue