- def __init__(self, *args, **kwargs):
- super(ScheduleForm, self).__init__(*args, **kwargs)
- self.fields['plan'].empty_label = None
+ 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
+ }
+ )
+ return value
+
+ def save(self, *args, **kwargs):
+ NewsletterForm.save(self, *args, **kwargs)
+ self.instance.source = self.referer or ''
+ return super().save(*args, **kwargs)