- def __init__(self, *args, request=None, **kwargs):
- super(ScheduleForm, self).__init__(*args, **kwargs)
- self.request = request
- self.plans = models.Plan.objects.all()
- self.payment_methods = methods
- self.fields['amount'].required = False
-
- def clean(self):
- cleaned_data = super(ScheduleForm, self).clean()
-
- if 'plan' in cleaned_data:
- cleaned_data['amount'] = self.fields['amount'].clean(
- self.request.POST['amount-{}'.format(cleaned_data['plan'].id)]
+ def __init__(self, referer=None, **kwargs):
+ self.referer = referer
+ super().__init__(**kwargs)
+
+ def clean_amount(self):
+ value = self.cleaned_data['amount']
+ club = models.Club.objects.first()
+ if club and value < club.min_amount:
+ raise forms.ValidationError(
+ _('Minimal amount is %(amount)d PLN.') % {
+ 'amount': club.min_amount
+ }