X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/94a4fcc7ab9e1713dc2defc8b35c875fc90f6fa5..2954f0e21a4c9adf96bb63c85339e7fa79d78e22:/src/club/forms.py?ds=sidebyside diff --git a/src/club/forms.py b/src/club/forms.py index dd088f730..22b0554d9 100644 --- a/src/club/forms.py +++ b/src/club/forms.py @@ -1,9 +1,8 @@ -# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. -# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. +# This file is part of Wolne Lektury, licensed under GNU Affero GPLv3 or later. +# Copyright © Fundacja Wolne Lektury. See NOTICE for more information. # from decimal import Decimal from django import forms -from django.utils.translation import gettext as _ from newsletter.forms import NewsletterForm from . import models, payment_methods from .payu.forms import CardTokenForm @@ -32,7 +31,8 @@ class DonationStep1Form(forms.ModelForm): 'monthly' ] - def __init__(self, *args, **kwargs): + def __init__(self, *args, referer=None, **kwargs): + self.referer = referer super().__init__(*args, **kwargs) club = models.Club.objects.first() if club is not None: @@ -49,6 +49,9 @@ class DonationStep1Form(forms.ModelForm): return state + def save(self, *args, **kwargs): + self.instance.source = self.referer + return super().save(*args, **kwargs) class DonationStep2Form(forms.ModelForm, NewsletterForm): @@ -65,8 +68,7 @@ class DonationStep2Form(forms.ModelForm, NewsletterForm): 'monthly': forms.HiddenInput, } - def __init__(self, referer=None, **kwargs): - self.referer = referer + def __init__(self, **kwargs): super().__init__(**kwargs) self.fields['first_name'].required = True @@ -84,11 +86,8 @@ class DonationStep2Form(forms.ModelForm, NewsletterForm): c, key, (lambda k: lambda: self[k])(key) )) - - def save(self, *args, **kwargs): NewsletterForm.save(self, *args, **kwargs) - self.instance.source = self.referer or '' instance = super().save(*args, **kwargs) consents = []