- if 'plan' in cleaned_data:
- cleaned_data['amount'] = self.fields['amount'].clean(
- self.request.POST['amount-{}'.format(cleaned_data['plan'].id)]
+
+
+class DonationStep2Form(forms.ModelForm, NewsletterForm):
+ class Meta:
+ model = models.Schedule
+ fields = [
+ 'first_name', 'last_name',
+ 'email', 'phone',
+ 'postal',
+ 'postal_code', 'postal_town', 'postal_country',
+ ]
+ widgets = {
+ 'amount': forms.HiddenInput,
+ 'monthly': forms.HiddenInput,
+ }
+
+ def __init__(self, referer=None, **kwargs):
+ self.referer = referer
+ super().__init__(**kwargs)
+
+ self.fields['first_name'].required = True
+ self.fields['last_name'].required = True
+ self.fields['phone'].required = True
+
+ self.consent = []
+ for c in models.Consent.objects.filter(active=True).order_by('order'):
+ key = f'consent{c.id}'
+ self.fields[key] = forms.BooleanField(
+ label=c.text,
+ required=c.required