DCL payment page: Get form data from session on error
This commit is contained in:
parent
4efc1b4943
commit
fcda0b5637
2 changed files with 15 additions and 0 deletions
|
@ -348,6 +348,10 @@ class PaymentOrderView(FormView):
|
||||||
form_kwargs.update({
|
form_kwargs.update({
|
||||||
'instance': self.request.user.billing_addresses.first()
|
'instance': self.request.user.billing_addresses.first()
|
||||||
})
|
})
|
||||||
|
if 'billing_address_data' in self.request.session:
|
||||||
|
form_kwargs.update({
|
||||||
|
'billing_address_data': self.request.session['billing_address_data']
|
||||||
|
})
|
||||||
return form_kwargs
|
return form_kwargs
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
|
|
|
@ -118,6 +118,12 @@ class EditCreditCardForm(forms.Form):
|
||||||
class BillingAddressForm(forms.ModelForm):
|
class BillingAddressForm(forms.ModelForm):
|
||||||
token = forms.CharField(widget=forms.HiddenInput(), required=False)
|
token = forms.CharField(widget=forms.HiddenInput(), required=False)
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
billing_address_data = kwargs.get('billing_address_data', {})
|
||||||
|
kwargs['initial'] = billing_address_data
|
||||||
|
super(BillingAddressForm, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = BillingAddress
|
model = BillingAddress
|
||||||
fields = ['cardholder_name', 'street_address',
|
fields = ['cardholder_name', 'street_address',
|
||||||
|
@ -136,6 +142,11 @@ class BillingAddressFormSignup(BillingAddressForm):
|
||||||
email = forms.EmailField(label=_('Email Address'))
|
email = forms.EmailField(label=_('Email Address'))
|
||||||
field_order = ['name', 'email']
|
field_order = ['name', 'email']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
billing_address_data = kwargs.get('billing_address_data', {})
|
||||||
|
kwargs['initial'] = billing_address_data
|
||||||
|
super(BillingAddressFormSignup, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class UserBillingAddressForm(forms.ModelForm):
|
class UserBillingAddressForm(forms.ModelForm):
|
||||||
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
|
user = forms.ModelChoiceField(queryset=CustomUser.objects.all(),
|
||||||
|
|
Loading…
Reference in a new issue