mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-08-04 06:30:27 +02:00
Deposit check logic changed
This commit is contained in:
@@ -594,8 +594,8 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
# Cacher les champs pendant l'inscription initiale
|
||||
if "first_year" in form.fields:
|
||||
del form.fields["first_year"]
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
if "deposit_given" in form.fields:
|
||||
del form.fields["deposit_given"]
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
if "deposit_type" in form.fields:
|
||||
@@ -704,8 +704,8 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
# Cacher les champs pendant l'inscription initiale
|
||||
if "first_year" in form.fields:
|
||||
del form.fields["first_year"]
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
if "deposit_given" in form.fields:
|
||||
del form.fields["deposit_given"]
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
|
||||
@@ -806,9 +806,9 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
||||
# The auto-json-format may cause issues with the default field remove
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
# Masquer le champ deposit_check pour tout le monde dans le formulaire de modification
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
# Masquer le champ deposit_given pour tout le monde dans le formulaire de modification
|
||||
if "deposit_given" in form.fields:
|
||||
del form.fields["deposit_given"]
|
||||
|
||||
# S'assurer que le champ deposit_type est obligatoire pour les 2A+
|
||||
if "deposit_type" in form.fields:
|
||||
@@ -818,6 +818,14 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
||||
form.fields["deposit_type"].required = True
|
||||
form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit")
|
||||
|
||||
if not self.object.first_year and self.object.deposit_type == 'check':
|
||||
form.fields["deposit_given"] = forms.BooleanField(
|
||||
required=False,
|
||||
initial=self.object.deposit_given,
|
||||
label=_("Deposit check given"),
|
||||
help_text=_("Tick if the deposit check has been given")
|
||||
)
|
||||
|
||||
if self.object.user.profile.soge:
|
||||
form.fields["soge_credit"].disabled = True
|
||||
form.fields["soge_credit"].help_text = _("You already opened an account in the Société générale.")
|
||||
@@ -1016,17 +1024,18 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
form.fields["last_name"].initial = registration.user.last_name
|
||||
form.fields["first_name"].initial = registration.user.first_name
|
||||
|
||||
# Ajouter le champ deposit_check uniquement pour les non-première année et le rendre obligatoire
|
||||
# Ajouter le champ deposit_given uniquement pour les non-première année et le rendre obligatoire
|
||||
if not registration.first_year:
|
||||
if registration.deposit_type == 'check':
|
||||
form.fields["deposit_check"] = forms.BooleanField(
|
||||
form.fields["deposit_given"] = forms.BooleanField(
|
||||
required=True,
|
||||
initial=registration.deposit_check,
|
||||
disabled=True,
|
||||
initial=registration.deposit_given,
|
||||
label=_("Deposit check given"),
|
||||
help_text=_("Please make sure the check is given before validating the registration")
|
||||
help_text=_("Only treasurers can validate this field")
|
||||
)
|
||||
else:
|
||||
form.fields["deposit_check"] = forms.BooleanField(
|
||||
form.fields["deposit_given"] = forms.BooleanField(
|
||||
required=True,
|
||||
initial=False,
|
||||
label=_("Create deposit transaction"),
|
||||
@@ -1067,8 +1076,8 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
club = registration.wei
|
||||
user = registration.user
|
||||
|
||||
if "deposit_check" in form.data:
|
||||
registration.deposit_check = form.data["deposit_check"] == "on"
|
||||
if "deposit_given" in form.data:
|
||||
registration.deposit_given = form.data["deposit_given"] == "on"
|
||||
registration.save()
|
||||
membership = form.instance
|
||||
membership.user = user
|
||||
@@ -1180,7 +1189,7 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
def form_invalid(self, form):
|
||||
registration = getattr(form.instance, "registration", None)
|
||||
if registration is not None:
|
||||
registration.deposit_check = False
|
||||
registration.deposit_given = False
|
||||
registration.save()
|
||||
return super().form_invalid(form)
|
||||
|
||||
|
Reference in New Issue
Block a user