+class PayUCardTokenForm(CardTokenForm):
+ def get_queryset(self, view):
+ return view.get_schedule().payucardtoken_set
+
+
+
+class DonationStep1Form(forms.ModelForm):
+ switch = forms.CharField()
+ single_amount = forms.IntegerField(required=False)
+ monthly_amount = forms.IntegerField(required=False)
+ single_amount_selected = forms.IntegerField(required=False)
+ monthly_amount_selected = forms.IntegerField(required=False)
+ custom_amount = forms.IntegerField(required=False)
+
+ amount = forms.IntegerField(required=False) # hidden
+
+ class Meta:
+ model = models.Schedule
+ fields = [
+ 'amount',
+ 'monthly'
+ ]
+
+ def __init__(self, *args, **kwargs):
+ super().__init__(*args, **kwargs)
+ club = models.Club.objects.first()
+ if club is not None:
+ self.fields['custom_amount'].widget.attrs['min'] = club.min_amount
+
+ def clean(self):
+ state = {}
+ state['monthly'] = self.cleaned_data['switch'] == 'monthly'
+ which = 'monthly' if state['monthly'] else 'single'
+ state['amount'] = \
+ self.cleaned_data[f'{which}_amount'] or \
+ self.cleaned_data['custom_amount'] or \
+ self.cleaned_data[f'{which}_amount_selected']
+
+ return state
+
+
+
+class DonationStep2Form(forms.ModelForm, NewsletterForm):