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
6 from newsletter.forms import NewsletterForm
8 from .payu.forms import CardTokenForm
11 class ScheduleForm(NewsletterForm, forms.ModelForm):
13 model = models.Schedule
14 fields = ['monthly', 'amount', 'email']
16 'amount': forms.HiddenInput,
17 'monthly': forms.HiddenInput,
20 def clean_amount(self):
21 value = self.cleaned_data['amount']
22 club = models.Club.objects.first()
23 if club and value < club.min_amount:
24 raise forms.ValidationError('Minimalna kwota to %d zł.' % club.min_amount)
28 class PayUCardTokenForm(CardTokenForm):
29 def get_queryset(self, view):
30 return view.get_schedule().payucardtoken_set