From cdbab541bce65dd314f8febe62713cadf1819f2e Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Sun, 8 Oct 2017 17:29:10 +0200 Subject: [PATCH] Refactor billing_address_form for not logged in case --- datacenterlight/views.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/datacenterlight/views.py b/datacenterlight/views.py index 041a7710..4b26da6d 100644 --- a/datacenterlight/views.py +++ b/datacenterlight/views.py @@ -348,7 +348,6 @@ class PaymentOrderView(FormView): else: billing_address_data = {} - billing_address_form = None if self.request.user.is_authenticated(): if billing_address_data: billing_address_form = BillingAddressForm( @@ -360,17 +359,17 @@ class PaymentOrderView(FormView): prefix='billing_address_form', instance=self.request.user.billing_addresses.first() ) + else: + billing_address_form = BillingAddressFormSignup( + prefix='billing_address_form_signup', + initial=billing_address_data + ) context.update({ 'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'site_url': reverse('datacenterlight:index'), 'login_form': HostingUserLoginForm(prefix='login_form'), 'billing_address_form': billing_address_form - if self.request.user.is_authenticated() else - BillingAddressFormSignup( - prefix='billing_address_form_signup', - initial=billing_address_data - ) }) return context