Merge branch 'release/v9.04'
This commit is contained in:
@@ -19,9 +19,29 @@ from django.forms import formset_factory
|
|||||||
from utils import landingpages
|
from utils import landingpages
|
||||||
from metrics import axes
|
from metrics import axes
|
||||||
|
|
||||||
|
class FlexibleDecimalField(forms.DecimalField):
|
||||||
|
|
||||||
|
def to_python(self, value):
|
||||||
|
# check decimal symbol
|
||||||
|
comma_index = 0
|
||||||
|
dot_index = 0
|
||||||
|
try:
|
||||||
|
comma_index = value.index(',')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
dot_index = value.index('.')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
if value:
|
||||||
|
if comma_index > dot_index:
|
||||||
|
value = value.replace('.', '').replace(',', '.')
|
||||||
|
return super(FlexibleDecimalField, self).to_python(value)
|
||||||
|
|
||||||
# BillingForm form
|
# BillingForm form
|
||||||
class BillingForm(forms.Form):
|
class BillingForm(forms.Form):
|
||||||
amount = forms.FloatField(required=True)
|
amount = FlexibleDecimalField(required=True,decimal_places=2,
|
||||||
|
max_digits=8)
|
||||||
plan = forms.IntegerField(widget=forms.HiddenInput())
|
plan = forms.IntegerField(widget=forms.HiddenInput())
|
||||||
payment_method_nonce = forms.CharField(max_length=255,required=True)
|
payment_method_nonce = forms.CharField(max_length=255,required=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user