From 570810105e076026f7d25d43c385312d51f8f4b8 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Tue, 20 Apr 2021 10:00:24 +0200 Subject: [PATCH] Invoice display in client dashboard --- clients/views.py | 8 ++++++-- payment/models.py | 1 + templates/clients/dashboard.html | 12 ++++++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/clients/views.py b/clients/views.py index 7497b54..091301a 100644 --- a/clients/views.py +++ b/clients/views.py @@ -1,4 +1,4 @@ -from django.views.generic import CreateView, UpdateView, TemplateView, ListView +from django.views.generic import CreateView, UpdateView, TemplateView, ListView, DetailView from django.urls import reverse_lazy from django.shortcuts import redirect from django.contrib import messages @@ -71,9 +71,13 @@ class ClientProfileView(InConstructionMixin, LoginRequiredMixin, UpdateView): except ClientProfile.DoesNotExist: return redirect("clients:register") -class ClientDashboardView(InConstructionMixin, LoginRequiredMixin, TemplateView): +class ClientDashboardView(InConstructionMixin, ClientProfileRequiredMixin, DetailView): + model = ClientProfile template_name = "clients/dashboard.html" + def get_object(self): + return self.request.user.clientprofile + class ClientBookingsView(InConstructionMixin, ClientProfileRequiredMixin, ListView): model = Inquiry template_name = "clients/bookings.html" diff --git a/payment/models.py b/payment/models.py index 2f14dc9..653c994 100644 --- a/payment/models.py +++ b/payment/models.py @@ -52,6 +52,7 @@ class Invoice(models.Model): tax_rate = models.DecimalField(max_digits=4, decimal_places=2) invoice = models.FileField(null=True, blank=True, upload_to=invoice_upload_path) inquiry = models.OneToOneField(Inquiry, null=True, blank=True, on_delete=models.SET_NULL) + created = models.DateTimeField(auto_now_add=True) @property def price_net(self): diff --git a/templates/clients/dashboard.html b/templates/clients/dashboard.html index f88e17d..0abafd9 100644 --- a/templates/clients/dashboard.html +++ b/templates/clients/dashboard.html @@ -82,18 +82,22 @@
+ {% for invoice in object.user.invoice_set.all %} + {% if invoice.inquiry %} - + + {% endif %} + {% endfor %}

Reiseanfrage

    -
  • Bezahlt
  • -
  • Anfrage: #00214
  • -
  • Erstellt: 25.03.2021
  • +
  • {% if invoice.is_paid %}Bezahlt{% else %}Unbezahlt{% endif %}
  • +
  • Anfrage: #{{ invoice.inquiry.id }}
  • +
  • Erstellt: {{ invoice.created|date:"d.m.Y" }}
Rechnung anzeigen