From 6d4af0c193dd871a054adeb77b741296608a508b Mon Sep 17 00:00:00 2001 From: PCoder Date: Thu, 4 Apr 2019 08:10:08 +0200 Subject: [PATCH] Fix getting number of mabs of a user --- hosting/views.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 45fd845f..b3b5c1f8 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -83,16 +83,17 @@ class DashboardView(LoginRequiredMixin, View): @method_decorator(decorators) def get(self, request, *args, **kwargs): context = self.get_context_data() + context['has_invoices'] = False try: - MonthlyHostingBill.objects.get( + bills = MonthlyHostingBill.objects.filter( customer=self.request.user.stripecustomer ) - context['has_invoices'] = True + if len(bills) > 0: + 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)