1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
4 from decimal import Decimal
5 from django import forms
7 from .payu.forms import CardTokenForm
10 class ScheduleForm(forms.ModelForm):
12 model = models.Schedule
13 fields = ['monthly', 'amount', 'email']
15 'amount': forms.HiddenInput,
16 'monthly': forms.HiddenInput,
19 def clean_amount(self):
20 value = self.cleaned_data['amount']
21 club = models.Club.objects.first()
22 if club and value < club.min_amount:
23 raise forms.ValidationError('Minimalna kwota to %d zł.' % club.min_amount)
27 class PayUCardTokenForm(CardTokenForm):
28 def get_queryset(self, view):
29 return view.get_schedule().payucardtoken_set