1 from django import forms
2 from .models import Offer
5 class DummyForm(forms.Form):
6 amount = forms.DecimalField()
7 name = forms.CharField()
8 email = forms.EmailField()
10 def __init__(self, offer, *args, **kwargs):
12 super(DummyForm, self).__init__(*args, **kwargs)
14 def clean_amount(self):
15 if self.cleaned_data['amount'] <= 0:
16 raise forms.ValidationError("A!")
17 return self.cleaned_data['amount']
20 if self.offer != Offer.current():
21 raise forms.ValidationError("B!")
22 return self.cleaned_data
25 print self.cleaned_data
26 return self.offer.fund(
27 name=self.cleaned_data['name'],
28 email=self.cleaned_data['email'],
29 amount=self.cleaned_data['amount'])