commit
0ddbdbc944
|
@ -645,10 +645,10 @@ class CampaignPledgeForm(forms.Form):
|
|||
raise forms.ValidationError(_("Sorry, you must pledge at least $%s to select that premium." % (self.premium.amount)))
|
||||
return self.cleaned_data
|
||||
|
||||
class PlainCCForm(forms.Form):
|
||||
stripe_token = forms.CharField(required=False, widget=forms.HiddenInput())
|
||||
class TokenCCMixin(forms.Form):
|
||||
stripe_token = forms.CharField(required=True, widget=forms.HiddenInput())
|
||||
|
||||
class BaseCCForm(PlainCCForm):
|
||||
class BaseCCMixin(forms.Form):
|
||||
work_id = forms.IntegerField(required=False, widget=forms.HiddenInput())
|
||||
preapproval_amount= forms.DecimalField(
|
||||
required=False,
|
||||
|
@ -657,12 +657,23 @@ class BaseCCForm(PlainCCForm):
|
|||
decimal_places=2,
|
||||
label="Amount",
|
||||
)
|
||||
class UserCCMixin(forms.Form):
|
||||
username = forms.CharField(max_length=30, required=True, widget=forms.HiddenInput())
|
||||
|
||||
class PlainCCForm(TokenCCMixin, forms.Form):
|
||||
pass
|
||||
|
||||
class BaseCCForm(BaseCCMixin, TokenCCMixin, forms.Form):
|
||||
pass
|
||||
|
||||
class AnonCCForm(BaseCCForm):
|
||||
email = forms.CharField(max_length=30, required=False, widget=forms.TextInput())
|
||||
|
||||
class CCForm(BaseCCForm):
|
||||
username = forms.CharField(max_length=30, required=True, widget=forms.HiddenInput())
|
||||
class CCForm(UserCCMixin, BaseCCForm):
|
||||
pass
|
||||
|
||||
class AccountCCForm( BaseCCMixin, UserCCMixin, forms.Form):
|
||||
pass
|
||||
|
||||
class DonateForm(forms.Form):
|
||||
preapproval_amount = forms.DecimalField( widget=forms.HiddenInput() )
|
||||
|
|
|
@ -108,6 +108,7 @@ from regluit.frontend.forms import (
|
|||
getTransferCreditForm,
|
||||
CCForm,
|
||||
AnonCCForm,
|
||||
AccountCCForm,
|
||||
CloneCampaignForm,
|
||||
PlainCCForm,
|
||||
WorkForm,
|
||||
|
@ -1285,6 +1286,8 @@ class FundView(FormView):
|
|||
def get_form_class(self):
|
||||
if self.request.user.is_anonymous():
|
||||
return AnonCCForm
|
||||
elif self.request.user.profile.account:
|
||||
return AccountCCForm
|
||||
else:
|
||||
return CCForm
|
||||
|
||||
|
@ -1304,8 +1307,10 @@ class FundView(FormView):
|
|||
|
||||
if kwargs.has_key('data'):
|
||||
data = kwargs['data'].copy()
|
||||
kwargs['data'] = data
|
||||
else:
|
||||
data = {}
|
||||
kwargs['initial'] = data
|
||||
|
||||
data.update(
|
||||
{'preapproval_amount':self.transaction.needed_amount,
|
||||
|
@ -1313,9 +1318,6 @@ class FundView(FormView):
|
|||
'work_id':self.transaction.campaign.work.id,
|
||||
'title':self.transaction.campaign.work.title}
|
||||
)
|
||||
|
||||
kwargs['data'] = data
|
||||
|
||||
return kwargs
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
|
@ -1336,7 +1338,7 @@ class FundView(FormView):
|
|||
|
||||
def form_valid(self, form):
|
||||
p = PaymentManager()
|
||||
stripe_token = form.cleaned_data["stripe_token"]
|
||||
stripe_token = form.cleaned_data.get("stripe_token", None)
|
||||
self.transaction.host = settings.PAYMENT_PROCESSOR
|
||||
return_url = "%s?tid=%s" % (reverse('pledge_complete'),self.transaction.id)
|
||||
|
||||
|
|
Loading…
Reference in New Issue