From d0455fbafb52024b790d8c3c13b1fc9506c57806 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 4 Feb 2020 17:10:11 +0530 Subject: [PATCH 1/4] Remove unused import --- datacenterlight/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index abd17964..3c9be6db 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -29,7 +29,7 @@ from utils.forms import ( ) from utils.hosting_utils import ( get_vm_price_with_vat, get_all_public_keys, get_vat_rate_for_country, - get_vm_price_for_given_vat, round_up + get_vm_price_for_given_vat ) from utils.stripe_utils import StripeUtils from utils.tasks import send_plain_email_task From e25ed77538b13f40b9537941d3780341284973c4 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 25 Feb 2020 11:13:26 +0530 Subject: [PATCH 2/4] Handle invoice for no stripe error --- hosting/views.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index 17af51fd..bffaa072 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1297,9 +1297,12 @@ class InvoiceListView(LoginRequiredMixin, TemplateView): except CustomUser.DoesNotExist as dne: logger.debug("User does not exist") cu = self.request.user - invs = stripe.Invoice.list(customer=cu.stripecustomer.stripe_id, - count=100) - paginator = Paginator(invs.data, 10) + if cu.stripecustomer: + invs = stripe.Invoice.list(customer=cu.stripecustomer.stripe_id, + count=100) + else: + invs = [] + paginator = Paginator(invs.data if len(invs) > 0 else [], 10) try: invs_page = paginator.page(page) except PageNotAnInteger: @@ -1308,11 +1311,14 @@ class InvoiceListView(LoginRequiredMixin, TemplateView): invs_page = paginator.page(paginator.num_pages) else: try: - invs = stripe.Invoice.list( - customer=self.request.user.stripecustomer.stripe_id, - count=100 - ) - paginator = Paginator(invs.data, 10) + if self.request.user.stripecustomer: + invs = stripe.Invoice.list( + customer=self.request.user.stripecustomer.stripe_id, + count=100 + ) + else: + invs = [] + paginator = Paginator(invs.data if len(invs) > 0 else [], 10) try: invs_page = paginator.page(page) except PageNotAnInteger: From 56d3d4e7fe25272443f14e1e12787484abad2661 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 25 Feb 2020 11:50:39 +0530 Subject: [PATCH 3/4] Check invoice list from stripe only if we have a stripecustomer --- hosting/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hosting/views.py b/hosting/views.py index bffaa072..0cf555f2 100644 --- a/hosting/views.py +++ b/hosting/views.py @@ -1297,7 +1297,7 @@ class InvoiceListView(LoginRequiredMixin, TemplateView): except CustomUser.DoesNotExist as dne: logger.debug("User does not exist") cu = self.request.user - if cu.stripecustomer: + if hasattr(cu, 'stripecustomer'): invs = stripe.Invoice.list(customer=cu.stripecustomer.stripe_id, count=100) else: @@ -1311,7 +1311,7 @@ class InvoiceListView(LoginRequiredMixin, TemplateView): invs_page = paginator.page(paginator.num_pages) else: try: - if self.request.user.stripecustomer: + if hasattr(self.request.user, "stripecustomer"): invs = stripe.Invoice.list( customer=self.request.user.stripecustomer.stripe_id, count=100 From f2b92a3670c4fab5a3df032cf2ec63b6f4fcebb7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 25 Feb 2020 12:02:44 +0530 Subject: [PATCH 4/4] Update Changelog for 2.10.3 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index df611d74..23d2434c 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.10.3: 2020-02-25 + * Handle 500 error in invoice list page for non-stripe users (MR!731) 2.10.2: 2020-02-04 * Introduce base price for VMs and let admins add stripe_coupon_id (MR!730) Notes for deployment: