From 6a7b5459cebc5cd4d065b7b10b6b1981da3eddcf Mon Sep 17 00:00:00 2001 From: PCoder Date: Fri, 12 Apr 2019 08:14:52 +0200 Subject: [PATCH] Allow admin to list invoices --- hosting/views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 484cbe32..15476fd4 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1169,9 +1169,15 @@ class InvoiceListView(LoginRequiredMixin, ListView): def get_context_data(self, **kwargs): context = super(InvoiceListView, self).get_context_data(**kwargs) - mabs = MonthlyHostingBill.objects.filter( - customer__user=self.request.user - ) + 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'] + ) + else: + mabs = MonthlyHostingBill.objects.filter( + customer__user=self.request.user + ) ips_dict = {} for mab in mabs: try: