From 1b2102e996789db8a8c6bc1e71f1798a87731a22 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Wed, 19 May 2021 15:04:03 +0200 Subject: [PATCH] Record club payment source. --- src/club/forms.py | 5 ++ src/club/locale/pl/LC_MESSAGES/django.mo | Bin 7601 -> 7634 bytes src/club/locale/pl/LC_MESSAGES/django.po | 88 ++++++++++---------- src/club/migrations/0026_schedule_source.py | 18 ++++ src/club/models.py | 4 +- src/club/views.py | 5 ++ 6 files changed, 77 insertions(+), 43 deletions(-) create mode 100644 src/club/migrations/0026_schedule_source.py diff --git a/src/club/forms.py b/src/club/forms.py index 5ca08271f..2664fa353 100644 --- a/src/club/forms.py +++ b/src/club/forms.py @@ -20,6 +20,10 @@ class ScheduleForm(forms.ModelForm, NewsletterForm): 'monthly': forms.HiddenInput, } + 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() @@ -33,6 +37,7 @@ class ScheduleForm(forms.ModelForm, NewsletterForm): def save(self, *args, **kwargs): NewsletterForm.save(self, *args, **kwargs) + self.instance.source = self.referer or '' return super().save(*args, **kwargs) diff --git a/src/club/locale/pl/LC_MESSAGES/django.mo b/src/club/locale/pl/LC_MESSAGES/django.mo index 902a989b00848cf88d557e785749163666d7bd18..c0679319f19eb139fd5566986f70134e8d89d932 100644 GIT binary patch delta 1630 zcmXZcTS(MF6vy$irMqQou69|qEVFX0FkL}1O}kQ=7zK7!!^$p3C>nwZwOt;n2kEj! zQAAM`2=!n~K?zZqFFvM0g82~A4T6FSx>4VsjO>3u^PipnnKS1Vpb{=eC02z>tOoVmPWSr( z*WZeIu025gV;-~Pbo{2HkexD(6A+%nPUXIm`YF?En2FC(D|m~l#0OL&s<#qPK=r4g z78FJ$R*L1g7M0iqRHBz7G?>e7xB)TD;r=gXVm8sVyVqbY9zY$_E2vZO5Xs&8og>cg zPA@x92?tT9AOn?fzPpbU)0jg?B^F}~GPm7FV%Q7RN``PTen71xizB0z97K(8#v6DV z_hL>uvG6Qv!Z93vHoo~$38fI8R-FAF{_s|LK5j|XW487?f&FIbRY5bF+f`^Wb_Y3Yg8_nv5q Iwq`8(5AqS5z5oCK delta 1608 zcmXZcTS!z<6vpv2YBO5ej7FK)yi{5;=%`pKhJg`Tf>xFnkW>g03M+`pV7drJ5lDme z(Cr}zDvDyLm!g+0C|yX29)cnW0`b8l3!qTLF^=F;yn|$5&#?^OVi5nKiWg)OjjO=Z zxCKk`J%%u0Apxn>Rh%fI^{C97P$k-qTA$q6Q?1UEEm%;h-?SjfC{t;HQ`oN1>2n6&VEz?2T|jO za0Qi>t1Ty{tnJ3n&~+0d?{Zi;XS^YAt*@>i$|jH3dWL zY$a~O5Gt@iRG`O^rR+@D4Y-2EbbP}+^s|a~br}Y68|w8uf!h7okR=Is$qTH;aa1M?cvX~1D{6cPUdR2o8&fmQ z4&Y(bf>X$bx1Xqh;`tL$1(J~KVN2yi3uQTr<}O%;vksN%M%QjbRjLPz@EoetQPlhX z6t&Ph)U*EJ+MiIB_=>!t_A4gOKc2d3vjtEY<)H?wL2aT2RK!iFKwDAIyc?C_0IFg~ zQR6S*YP^iA@TKejj+*~BYJ7m_n5Fl>m=jIhfK=I7UYVbuLs zUH>g)bI1N}UE$@gvcbVm02 nmU(tY&-)%FMj8WyDWPC_Szf5JrlPW>EEJsxJWh^W%BlSilD(1f diff --git a/src/club/locale/pl/LC_MESSAGES/django.po b/src/club/locale/pl/LC_MESSAGES/django.po index e56693950..02f756882 100644 --- a/src/club/locale/pl/LC_MESSAGES/django.po +++ b/src/club/locale/pl/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"PO-Revision-Date: 2021-01-20 14:34+0100\n" +"PO-Revision-Date: 2021-05-19 15:02+0200\n" "Last-Translator: \n" "Language-Team: \n" "Language: pl\n" @@ -31,7 +31,7 @@ msgstr "harmonogram przedawniony" msgid "Club" msgstr "Towarzystwo" -#: club/forms.py:26 +#: club/forms.py:32 #, python-format msgid "Minimal amount is %(amount)d PLN." msgstr "Minimalna kwota to %(amount)d zł." @@ -68,103 +68,107 @@ msgstr "towarzystwo" msgid "clubs" msgstr "towarzystwa" -#: club/models.py:47 +#: club/models.py:48 msgid "key" msgstr "klucz" -#: club/models.py:48 +#: club/models.py:49 msgid "email" msgstr "email" -#: club/models.py:49 club/models.py:155 +#: club/models.py:50 club/models.py:143 msgid "membership" msgstr "członkostwo" -#: club/models.py:50 -msgid "payed at" -msgstr "opłacona" - #: club/models.py:51 -msgid "expires_at" -msgstr "wygasa" - -#: club/models.py:71 msgid "amount" msgstr "kwota" -#: club/models.py:72 club/templates/club/payment_form.html:21 +#: club/models.py:52 club/templates/club/payment_form.html:21 msgid "monthly" msgstr "miesięcznie" -#: club/models.py:73 +#: club/models.py:53 msgid "yearly" msgstr "rocznie" -#: club/models.py:75 +#: club/models.py:55 +msgid "source" +msgstr "źródło" + +#: club/models.py:57 msgid "cancelled" msgstr "anulowany" -#: club/models.py:76 +#: club/models.py:58 +msgid "payed at" +msgstr "opłacona" + +#: club/models.py:59 msgid "started at" msgstr "start" -#: club/models.py:79 +#: club/models.py:60 +msgid "expires_at" +msgstr "wygasa" + +#: club/models.py:64 msgid "schedule" msgstr "harmonogram" -#: club/models.py:80 +#: club/models.py:65 msgid "schedules" msgstr "harmonogramy" -#: club/models.py:147 +#: club/models.py:135 msgid "user" msgstr "użytkownik" -#: club/models.py:148 +#: club/models.py:136 msgid "created at" msgstr "utworzone" -#: club/models.py:149 club/models.py:210 +#: club/models.py:137 club/models.py:198 msgid "name" msgstr "nazwisko" -#: club/models.py:150 +#: club/models.py:138 msgid "manual" msgstr "ustawiony ręcznie" -#: club/models.py:151 +#: club/models.py:139 msgid "notes" msgstr "notatki" -#: club/models.py:152 +#: club/models.py:140 msgid "updated at" msgstr "aktualizacja" -#: club/models.py:156 +#: club/models.py:144 msgid "memberships" msgstr "członkostwa" -#: club/models.py:193 +#: club/models.py:181 msgid "days before" msgstr "dni przed" -#: club/models.py:194 +#: club/models.py:182 msgid "subject" msgstr "temat" -#: club/models.py:195 club/payu/models.py:140 +#: club/models.py:183 club/payu/models.py:140 msgid "body" msgstr "treść" -#: club/models.py:198 +#: club/models.py:186 msgid "reminder email" msgstr "email z przypomnieniem" -#: club/models.py:199 +#: club/models.py:187 msgid "reminder emails" msgstr "emaile z przypomnieniem" -#: club/models.py:204 +#: club/models.py:192 #, python-format msgid "a day before expiration" msgid_plural "%d days before expiration" @@ -173,7 +177,7 @@ msgstr[1] "%d dni przed wygaśnięciem" msgstr[2] "%d dni przed wygaśnięciem" msgstr[3] "%d dni przed wygaśnięciem" -#: club/models.py:206 +#: club/models.py:194 #, python-format msgid "a day after expiration" msgid_plural "%d days after expiration" @@ -182,23 +186,23 @@ msgstr[1] "%d dni po wygaśnięciu" msgstr[2] "%d dni po wygaśnięciu" msgstr[3] "%d dni przed wygaśnięciem" -#: club/models.py:211 +#: club/models.py:199 msgid "photo" msgstr "zdjęcie" -#: club/models.py:212 +#: club/models.py:200 msgid "text" msgstr "tekst" -#: club/models.py:215 +#: club/models.py:203 msgid "ambassador" msgstr "ambasador" -#: club/models.py:216 +#: club/models.py:204 msgid "ambassadors" msgstr "ambasadorowie" -#: club/models.py:247 club/templates/club/index.html:7 +#: club/models.py:235 club/templates/club/index.html:7 #: club/templates/club/index.html:13 club/templates/club/thanks.html:6 #: club/templates/payu/rec_payment.html:5 msgid "Towarzystwo Przyjaciół Wolnych Lektur" @@ -321,11 +325,11 @@ msgstr "Dziękujemy, że chcesz razem z nami uwalniać książki!" msgid "See your past support." msgstr "Zobacz swoje dotychczasowe wsparcie." -#: club/templates/club/membership_form.html:40 +#: club/templates/club/membership_form.html:41 msgid "Help us get 100 new Friends by the end of the school semester." msgstr "Pomóż nam zdobyć 100 nowych Przyjaciół do końca semestru szkolnego." -#: club/templates/club/membership_form.html:41 +#: club/templates/club/membership_form.html:42 #, python-format msgid "" "\n" @@ -354,7 +358,7 @@ msgstr[3] "" "Od początku tej kampanii stałą wpłatą wsparło nas już %(supporters)s czytelników i czytelniczek," -#: club/templates/club/membership_form.html:46 +#: club/templates/club/membership_form.html:47 #, python-format msgid "" "\n" @@ -421,7 +425,7 @@ msgstr "" "\" href=\"https://nowoczesnapolska.org.pl/prywatnosc/\">polityce " "prywatności." -#: club/templates/club/payment_form.html:64 +#: club/templates/club/payment_form.html:65 msgid "Donate" msgstr "Wpłać" diff --git a/src/club/migrations/0026_schedule_source.py b/src/club/migrations/0026_schedule_source.py new file mode 100644 index 000000000..dce415314 --- /dev/null +++ b/src/club/migrations/0026_schedule_source.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.19 on 2021-05-19 10:11 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('club', '0025_auto_20201126_1250'), + ] + + operations = [ + migrations.AddField( + model_name='schedule', + name='source', + field=models.CharField(blank=True, max_length=255, verbose_name='source'), + ), + ] diff --git a/src/club/models.py b/src/club/models.py index b8ec095c2..babe6f568 100644 --- a/src/club/models.py +++ b/src/club/models.py @@ -51,7 +51,9 @@ class Schedule(models.Model): amount = models.DecimalField(_('amount'), max_digits=10, decimal_places=2) monthly = models.BooleanField(_('monthly'), default=True) yearly = models.BooleanField(_('yearly'), default=False) - + + source = models.CharField(_('source'), max_length=255, blank=True) + is_cancelled = models.BooleanField(_('cancelled'), default=False) payed_at = models.DateTimeField(_('payed at'), null=True, blank=True) started_at = models.DateTimeField(_('started at'), auto_now_add=True) diff --git a/src/club/views.py b/src/club/views.py index e93864cab..6a5c7d725 100644 --- a/src/club/views.py +++ b/src/club/views.py @@ -60,6 +60,11 @@ class JoinView(CreateView): 'email': self.request.user.email, } + def get_form_kwargs(self): + kwargs = super().get_form_kwargs() + kwargs['referer'] = self.request.META.get('HTTP_REFERER', '') + return kwargs + def form_valid(self, form): retval = super(JoinView, self).form_valid(form) if self.request.user.is_authenticated: -- 2.20.1