From a21b9275ea1f172049b679b505f9ae1456ecd277 Mon Sep 17 00:00:00 2001 From: korenstin Date: Mon, 5 Aug 2024 11:52:47 +0200 Subject: [PATCH] Add caution_check in the validation form, #96 --- apps/wei/forms/registration.py | 6 ++++++ apps/wei/views.py | 6 ++++++ locale/fr/LC_MESSAGES/django.po | 1 + 3 files changed, 13 insertions(+) diff --git a/apps/wei/forms/registration.py b/apps/wei/forms/registration.py index c851248d..cf0579aa 100644 --- a/apps/wei/forms/registration.py +++ b/apps/wei/forms/registration.py @@ -81,6 +81,11 @@ class WEIChooseBusForm(forms.Form): class WEIMembershipForm(forms.ModelForm): + caution_check = forms.BooleanField( + required=False, + label=_("Caution check given"), + ) + roles = forms.ModelMultipleChoiceField( queryset=WEIRole.objects, label=_("WEI Roles"), @@ -149,6 +154,7 @@ class WEIMembership1AForm(WEIMembershipForm): """ Used to confirm registrations of first year members without choosing a bus now. """ + caution_check = None roles = None def clean(self): diff --git a/apps/wei/views.py b/apps/wei/views.py index 7a0e32fe..76943198 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -900,6 +900,9 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView): form.fields["last_name"].initial = registration.user.last_name form.fields["first_name"].initial = registration.user.first_name + if "caution_check" in form.fields: + form.fields["caution_check"].initial = registration.caution_check + if registration.soge_credit: form.fields["credit_type"].disabled = True form.fields["credit_type"].initial = NoteSpecial.objects.get(special_type="Virement bancaire") @@ -941,6 +944,9 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView): club = registration.wei user = registration.user + if "caution_check" in form.data: + registration.caution_check = form.data["caution_check"] == "on" + registration.save() membership = form.instance membership.user = user membership.club = club diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index e3edfeea..47f49d42 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -3001,6 +3001,7 @@ msgid "Credit from Société générale" msgstr "Crédit de la Société générale" #: apps/wei/models.py:188 +#: apps/wei/forms/registration.py:84 msgid "Caution check given" msgstr "Chèque de caution donné"