From 8dfee2bd83b4e2ff10d0f3b8e9dc65b6529d960f Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 4 Apr 2019 07:55:53 +0200 Subject: [PATCH] Show invoices only if the user's invoice were imported Else fallback to orders url as before --- hosting/templates/hosting/dashboard.html | 2 +- hosting/views.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/hosting/templates/hosting/dashboard.html b/hosting/templates/hosting/dashboard.html index d0204820..35ee9b6e 100644 --- a/hosting/templates/hosting/dashboard.html +++ b/hosting/templates/hosting/dashboard.html @@ -26,7 +26,7 @@ - +

{% trans "My Bills" %}

diff --git a/hosting/views.py b/hosting/views.py index af01ae86..6cdabecf 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -83,6 +83,14 @@ class DashboardView(LoginRequiredMixin, View): @method_decorator(decorators) def get(self, request, *args, **kwargs): context = self.get_context_data() + try: + MonthlyHostingBill.objects.get(email=self.request.user.email) + context['has_invoices'] = True + except MonthlyHostingBill.DoesNotExist as dne: + logger.error("{}'s monthly hosting bill not imported ?".format( + self.request.user.email + )) + context['has_invoices'] = False return render(request, self.template_name, context)