Refactor billing_address_form for not logged in case

This commit is contained in:
M.Ravi 2017-10-08 17:29:10 +02:00
parent 5a2657e357
commit cdbab541bc

View file

@ -348,7 +348,6 @@ class PaymentOrderView(FormView):
else: else:
billing_address_data = {} billing_address_data = {}
billing_address_form = None
if self.request.user.is_authenticated(): if self.request.user.is_authenticated():
if billing_address_data: if billing_address_data:
billing_address_form = BillingAddressForm( billing_address_form = BillingAddressForm(
@ -360,17 +359,17 @@ class PaymentOrderView(FormView):
prefix='billing_address_form', prefix='billing_address_form',
instance=self.request.user.billing_addresses.first() instance=self.request.user.billing_addresses.first()
) )
else:
billing_address_form = BillingAddressFormSignup(
prefix='billing_address_form_signup',
initial=billing_address_data
)
context.update({ context.update({
'stripe_key': settings.STRIPE_API_PUBLIC_KEY, 'stripe_key': settings.STRIPE_API_PUBLIC_KEY,
'site_url': reverse('datacenterlight:index'), 'site_url': reverse('datacenterlight:index'),
'login_form': HostingUserLoginForm(prefix='login_form'), 'login_form': HostingUserLoginForm(prefix='login_form'),
'billing_address_form': billing_address_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 return context