diff --git a/nummi/invoices/01_UtilisationENG.pdf b/nummi/invoices/01_UtilisationENG.pdf new file mode 100644 index 0000000..152cabb Binary files /dev/null and b/nummi/invoices/01_UtilisationENG.pdf differ diff --git a/nummi/invoices/artha.jpg b/nummi/invoices/artha.jpg new file mode 100644 index 0000000..5d987ca Binary files /dev/null and b/nummi/invoices/artha.jpg differ diff --git a/nummi/main/admin.py b/nummi/main/admin.py index 8c38f3f..ea0111a 100644 --- a/nummi/main/admin.py +++ b/nummi/main/admin.py @@ -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) diff --git a/nummi/main/templates/main/index.html b/nummi/main/templates/main/index.html new file mode 100644 index 0000000..6425f64 --- /dev/null +++ b/nummi/main/templates/main/index.html @@ -0,0 +1,7 @@ +{% if transactions %} + +{% endif %} diff --git a/nummi/main/templates/main/transaction.html b/nummi/main/templates/main/transaction.html new file mode 100644 index 0000000..2ed0971 --- /dev/null +++ b/nummi/main/templates/main/transaction.html @@ -0,0 +1,6 @@ +

{{ transaction }}

+ diff --git a/nummi/main/urls.py b/nummi/main/urls.py index 7ece5c9..6ed36f5 100644 --- a/nummi/main/urls.py +++ b/nummi/main/urls.py @@ -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/", views.transaction, name="transaction"), + path("invoice/", views.invoice, name="invoice"), +] diff --git a/nummi/main/views.py b/nummi/main/views.py index 5502aaf..8b61701 100644 --- a/nummi/main/views.py +++ b/nummi/main/views.py @@ -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")