From c232f4c1da66b8839fd7cb1a3ccb4ce39f6090b7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 12 Apr 2019 08:41:05 +0200 Subject: [PATCH] Fix error in obtaining customuser for mab --- hosting/views.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 15476fd4..6f41eaa8 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1171,9 +1171,16 @@ class InvoiceListView(LoginRequiredMixin, ListView): context = super(InvoiceListView, self).get_context_data(**kwargs) if ('user_email' in self.request.GET and self.request.user.email == settings.ADMIN_EMAIL): - mabs = MonthlyHostingBill.objects.filter( - customer__user=self.request.GET['user_email'] + user_email = self.request.GET['user_email'] + logger.debug( + "user_email = {}".format(user_email) ) + try: + cu = CustomUser.objects.get(user_email) + except CustomUser.DoesNotExist as dne: + logger.debug("User does not exist") + cu = self.request.user + mabs = MonthlyHostingBill.objects.filter(customer__user=cu) else: mabs = MonthlyHostingBill.objects.filter( customer__user=self.request.user