mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-07-17 06:45:53 +02:00
Rename 'caution' fields into 'deposit'
This commit is contained in:
@ -77,7 +77,7 @@ class WEIRegistrationViewSet(ReadProtectedModelViewSet):
|
||||
filter_backends = [DjangoFilterBackend, RegexSafeSearchFilter]
|
||||
filterset_fields = ['user', 'user__username', 'user__first_name', 'user__last_name', 'user__email',
|
||||
'user__note__alias__name', 'user__note__alias__normalized_name', 'wei', 'wei__name',
|
||||
'wei__email', 'wei__year', 'soge_credit', 'caution_check', 'birth_date', 'gender',
|
||||
'wei__email', 'wei__year', 'soge_credit', 'deposit_check', 'birth_date', 'gender',
|
||||
'clothing_cut', 'clothing_size', 'first_year', 'emergency_contact_name',
|
||||
'emergency_contact_phone', ]
|
||||
search_fields = ['$user__username', '$user__first_name', '$user__last_name', '$user__email',
|
||||
|
@ -24,7 +24,7 @@ class WEIForm(forms.ModelForm):
|
||||
"membership_end": DatePickerInput(),
|
||||
"date_start": DatePickerInput(),
|
||||
"date_end": DatePickerInput(),
|
||||
"caution_amount": AmountInput(),
|
||||
"deposit_amount": AmountInput(),
|
||||
}
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class WEIRegistrationForm(forms.ModelForm):
|
||||
fields = [
|
||||
'user', 'soge_credit', 'birth_date', 'gender', 'clothing_size',
|
||||
'health_issues', 'emergency_contact_name', 'emergency_contact_phone',
|
||||
'first_year', 'information_json', 'caution_check'
|
||||
'first_year', 'information_json', 'deposit_check'
|
||||
]
|
||||
widgets = {
|
||||
"user": Autocomplete(
|
||||
@ -58,7 +58,7 @@ class WEIRegistrationForm(forms.ModelForm):
|
||||
'minDate': '1900-01-01',
|
||||
'maxDate': '2100-01-01'
|
||||
}),
|
||||
"caution_check": forms.BooleanField(
|
||||
"deposit_check": forms.BooleanField(
|
||||
required=False,
|
||||
),
|
||||
}
|
||||
@ -66,10 +66,10 @@ class WEIRegistrationForm(forms.ModelForm):
|
||||
|
||||
class WEIRegistration2AForm(WEIRegistrationForm):
|
||||
class Meta(WEIRegistrationForm.Meta):
|
||||
fields = WEIRegistrationForm.Meta.fields + ['caution_type']
|
||||
fields = WEIRegistrationForm.Meta.fields + ['deposit_type']
|
||||
widgets = WEIRegistrationForm.Meta.widgets.copy()
|
||||
widgets.update({
|
||||
"caution_type": forms.RadioSelect(),
|
||||
"deposit_type": forms.RadioSelect(),
|
||||
})
|
||||
|
||||
|
||||
@ -173,7 +173,7 @@ class WEIMembership1AForm(WEIMembershipForm):
|
||||
"""
|
||||
Used to confirm registrations of first year members without choosing a bus now.
|
||||
"""
|
||||
caution_check = None
|
||||
deposit_check = None
|
||||
roles = None
|
||||
|
||||
def clean(self):
|
||||
|
@ -0,0 +1,40 @@
|
||||
# Generated by Django 4.2.23 on 2025-07-15 16:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('wei', '0014_weiclub_fee_soge_credit'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='weiclub',
|
||||
name='caution_amount',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='weiregistration',
|
||||
name='caution_check',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='weiregistration',
|
||||
name='caution_type',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='weiclub',
|
||||
name='deposit_amount',
|
||||
field=models.PositiveIntegerField(default=0, verbose_name='deposit amount'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='weiregistration',
|
||||
name='deposit_check',
|
||||
field=models.BooleanField(default=False, verbose_name='Deposit check given'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='weiregistration',
|
||||
name='deposit_type',
|
||||
field=models.CharField(choices=[('check', 'Check'), ('note', 'Note transaction')], default='check', max_length=16, verbose_name='deposit type'),
|
||||
),
|
||||
]
|
@ -33,8 +33,8 @@ class WEIClub(Club):
|
||||
verbose_name=_("date end"),
|
||||
)
|
||||
|
||||
caution_amount = models.PositiveIntegerField(
|
||||
verbose_name=_("caution amount"),
|
||||
deposit_amount = models.PositiveIntegerField(
|
||||
verbose_name=_("deposit amount"),
|
||||
default=0,
|
||||
)
|
||||
|
||||
@ -202,19 +202,19 @@ class WEIRegistration(models.Model):
|
||||
verbose_name=_("Credit from Société générale"),
|
||||
)
|
||||
|
||||
caution_check = models.BooleanField(
|
||||
deposit_check = models.BooleanField(
|
||||
default=False,
|
||||
verbose_name=_("Caution check given")
|
||||
verbose_name=_("Deposit check given")
|
||||
)
|
||||
|
||||
caution_type = models.CharField(
|
||||
deposit_type = models.CharField(
|
||||
max_length=16,
|
||||
choices=(
|
||||
('check', _("Check")),
|
||||
('note', _("Note transaction")),
|
||||
),
|
||||
default='check',
|
||||
verbose_name=_("caution type"),
|
||||
verbose_name=_("deposit type"),
|
||||
)
|
||||
|
||||
birth_date = models.DateField(
|
||||
|
@ -123,7 +123,7 @@ class WEIRegistrationTable(tables.Table):
|
||||
}
|
||||
model = WEIRegistration
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('user', 'user__first_name', 'user__last_name', 'first_year', 'caution_check',
|
||||
fields = ('user', 'user__first_name', 'user__last_name', 'first_year', 'deposit_check',
|
||||
'edit', 'validate', 'delete',)
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
@ -163,7 +163,7 @@ class WEIMembershipTable(tables.Table):
|
||||
model = WEIMembership
|
||||
template_name = 'django_tables2/bootstrap4.html'
|
||||
fields = ('user', 'user__last_name', 'user__first_name', 'registration__gender', 'user__profile__department',
|
||||
'year', 'bus', 'team', 'registration__caution_check', )
|
||||
'year', 'bus', 'team', 'registration__deposit_check', )
|
||||
row_attrs = {
|
||||
'class': 'table-row',
|
||||
'id': lambda record: "row-" + str(record.pk),
|
||||
|
@ -49,9 +49,9 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if club.caution_amount > 0 %}
|
||||
<dt class="col-xl-6">{% trans 'Caution amount'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ club.caution_amount|pretty_money }}</dd>
|
||||
{% if club.deposit_amount > 0 %}
|
||||
<dt class="col-xl-6">{% trans 'Deposit amount'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ club.deposit_amount|pretty_money }}</dd>
|
||||
{% endif %}
|
||||
|
||||
{% if "note.view_note"|has_perm:club.note %}
|
||||
|
@ -95,8 +95,8 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<dd class="col-xl-6"><em>{% trans "The algorithm didn't run." %}</em></dd>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<dt class="col-xl-6">{% trans 'caution check given'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ registration.caution_check|yesno }}</dd>
|
||||
<dt class="col-xl-6">{% trans 'Deposit check given'|capfirst %}</dt>
|
||||
<dd class="col-xl-6">{{ registration.deposit_check|yesno }}</dd>
|
||||
|
||||
{% with information=registration.information %}
|
||||
<dt class="col-xl-6">{% trans 'preferred bus'|capfirst %}</dt>
|
||||
@ -149,12 +149,12 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
<li>{% blocktrans trimmed with amount=fee|pretty_money %}
|
||||
Membership fees: {{ amount }}
|
||||
{% endblocktrans %}</li>
|
||||
{% if registration.caution_type == 'note' %}
|
||||
<li>{% blocktrans trimmed with amount=club.caution_amount|pretty_money %}
|
||||
{% if registration.deposit_type == 'note' %}
|
||||
<li>{% blocktrans trimmed with amount=club.deposit_amount|pretty_money %}
|
||||
Deposit (by Note transaction): {{ amount }}
|
||||
{% endblocktrans %}</li>
|
||||
{% else %}
|
||||
<li>{% blocktrans trimmed with amount=club.caution_amount|pretty_money %}
|
||||
<li>{% blocktrans trimmed with amount=club.deposit_amount|pretty_money %}
|
||||
Deposit (by check): {{ amount }}
|
||||
{% endblocktrans %}</li>
|
||||
{% endif %}
|
||||
@ -167,7 +167,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
|
||||
{% endblocktrans %}</p>
|
||||
</div>
|
||||
|
||||
{% if not registration.caution_check and not registration.first_year and registration.caution_type == 'check' %}
|
||||
{% if not registration.deposit_check and not registration.first_year and registration.caution_type == 'check' %}
|
||||
<div class="alert alert-danger">
|
||||
{% trans "The user didn't give her/his caution check." %}
|
||||
</div>
|
||||
|
@ -101,7 +101,7 @@ class TestWEIRegistration(TestCase):
|
||||
user_id=self.user.id,
|
||||
wei_id=self.wei.id,
|
||||
soge_credit=True,
|
||||
caution_check=True,
|
||||
deposit_check=True,
|
||||
birth_date=date(2000, 1, 1),
|
||||
gender="nonbinary",
|
||||
clothing_cut="male",
|
||||
@ -127,7 +127,7 @@ class TestWEIRegistration(TestCase):
|
||||
year=self.year + 1,
|
||||
date_start=str(self.year + 1) + "-09-01",
|
||||
date_end=str(self.year + 1) + "-09-03",
|
||||
caution_amount=12000,
|
||||
deposit_amount=12000,
|
||||
))
|
||||
qs = WEIClub.objects.filter(name="Create WEI Test", year=self.year + 1)
|
||||
self.assertTrue(qs.exists())
|
||||
@ -163,7 +163,7 @@ class TestWEIRegistration(TestCase):
|
||||
membership_end="2000-09-30",
|
||||
date_start="2000-09-01",
|
||||
date_end="2000-09-03",
|
||||
caution_amount=12000,
|
||||
deposit_amount=12000,
|
||||
))
|
||||
qs = WEIClub.objects.filter(name="Update WEI Test", id=self.wei.id)
|
||||
self.assertRedirects(response, reverse("wei:wei_detail", kwargs=dict(pk=self.wei.pk)), 302, 200)
|
||||
@ -322,7 +322,7 @@ class TestWEIRegistration(TestCase):
|
||||
bus=[],
|
||||
team=[],
|
||||
roles=[],
|
||||
caution_type='check'
|
||||
deposit_type='check'
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertFalse(response.context["membership_form"].is_valid())
|
||||
@ -340,7 +340,7 @@ class TestWEIRegistration(TestCase):
|
||||
bus=[self.bus.id],
|
||||
team=[self.team.id],
|
||||
roles=[role.id for role in WEIRole.objects.filter(~Q(name="1A") & ~Q(name="GC WEI")).all()],
|
||||
caution_type='check'
|
||||
deposit_type='check'
|
||||
))
|
||||
qs = WEIRegistration.objects.filter(user_id=user.id)
|
||||
self.assertTrue(qs.exists())
|
||||
@ -360,7 +360,7 @@ class TestWEIRegistration(TestCase):
|
||||
bus=[self.bus.id],
|
||||
team=[self.team.id],
|
||||
roles=[role.id for role in WEIRole.objects.filter(~Q(name="1A")).all()],
|
||||
caution_type='check'
|
||||
deposit_type='check'
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertTrue("This user is already registered to this WEI." in str(response.context["form"].errors))
|
||||
@ -513,7 +513,7 @@ class TestWEIRegistration(TestCase):
|
||||
team=[self.team.id],
|
||||
roles=[role.id for role in WEIRole.objects.filter(name="Adhérent⋅e WEI").all()],
|
||||
information_json=self.registration.information_json,
|
||||
caution_type='check'
|
||||
deposit_type='check'
|
||||
)
|
||||
)
|
||||
qs = WEIRegistration.objects.filter(user_id=self.user.id, soge_credit=False, clothing_size="M")
|
||||
@ -568,7 +568,7 @@ class TestWEIRegistration(TestCase):
|
||||
team=[self.team.id],
|
||||
roles=[role.id for role in WEIRole.objects.filter(name="Adhérent⋅e WEI").all()],
|
||||
information_json=self.registration.information_json,
|
||||
caution_type='check'
|
||||
deposit_type='check'
|
||||
)
|
||||
)
|
||||
qs = WEIRegistration.objects.filter(user_id=self.user.id, clothing_size="L")
|
||||
@ -592,7 +592,7 @@ class TestWEIRegistration(TestCase):
|
||||
team=[],
|
||||
roles=[],
|
||||
information_json=self.registration.information_json,
|
||||
caution_type='check'
|
||||
deposit_type='check'
|
||||
)
|
||||
)
|
||||
self.assertFalse(response.context["membership_form"].is_valid())
|
||||
@ -642,7 +642,7 @@ class TestWEIRegistration(TestCase):
|
||||
last_name="admin",
|
||||
first_name="admin",
|
||||
bank="Société générale",
|
||||
caution_check=True,
|
||||
deposit_check=True,
|
||||
))
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertFalse(response.context["form"].is_valid())
|
||||
@ -657,7 +657,7 @@ class TestWEIRegistration(TestCase):
|
||||
last_name="admin",
|
||||
first_name="admin",
|
||||
bank="Société générale",
|
||||
caution_check=True,
|
||||
deposit_check=True,
|
||||
))
|
||||
self.assertRedirects(response, reverse("wei:wei_registrations", kwargs=dict(pk=self.registration.wei.pk)), 302, 200)
|
||||
|
||||
@ -813,7 +813,7 @@ class TestWeiAPI(TestAPI):
|
||||
user_id=self.user.id,
|
||||
wei_id=self.wei.id,
|
||||
soge_credit=True,
|
||||
caution_check=True,
|
||||
deposit_check=True,
|
||||
birth_date=date(2000, 1, 1),
|
||||
gender="nonbinary",
|
||||
clothing_cut="male",
|
||||
|
@ -560,12 +560,12 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
# Cacher les champs pendant l'inscription initiale
|
||||
if "first_year" in form.fields:
|
||||
del form.fields["first_year"]
|
||||
if "caution_check" in form.fields:
|
||||
del form.fields["caution_check"]
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
if "caution_type" in form.fields:
|
||||
del form.fields["caution_type"]
|
||||
if "deposit_type" in form.fields:
|
||||
del form.fields["deposit_type"]
|
||||
|
||||
if "soge_credit" in form.fields:
|
||||
form.fields["soge_credit"].help_text = _('Check if you will open a Société Générale account')
|
||||
@ -670,16 +670,16 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
# Cacher les champs pendant l'inscription initiale
|
||||
if "first_year" in form.fields:
|
||||
del form.fields["first_year"]
|
||||
if "caution_check" in form.fields:
|
||||
del form.fields["caution_check"]
|
||||
if "deposit_check" in form.fields:
|
||||
del form.fields["deposit_check"]
|
||||
if "information_json" in form.fields:
|
||||
del form.fields["information_json"]
|
||||
|
||||
# S'assurer que le champ caution_type est obligatoire
|
||||
if "caution_type" in form.fields:
|
||||
form.fields["caution_type"].required = True
|
||||
form.fields["caution_type"].help_text = _("Choose how you want to pay the deposit")
|
||||
form.fields["caution_type"].widget = forms.RadioSelect(choices=form.fields["caution_type"].choices)
|
||||
# S'assurer que le champ deposit_type est obligatoire
|
||||
if "deposit_type" in form.fields:
|
||||
form.fields["deposit_type"].required = True
|
||||
form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit")
|
||||
form.fields["deposit_type"].widget = forms.RadioSelect(choices=form.fields["deposit_type"].choices)
|
||||
|
||||
return form
|
||||
|
||||
@ -708,7 +708,7 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
form.instance.information = information
|
||||
|
||||
# Sauvegarder le type de caution
|
||||
form.instance.caution_type = form.cleaned_data["caution_type"]
|
||||
form.instance.deposit_type = form.cleaned_data["deposit_type"]
|
||||
form.instance.save()
|
||||
|
||||
if 'treasury' in settings.INSTALLED_APPS:
|
||||
@ -780,15 +780,15 @@ 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 caution_check pour tout le monde dans le formulaire de modification
|
||||
if "caution_check" in form.fields:
|
||||
del form.fields["caution_check"]
|
||||
# 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"]
|
||||
|
||||
# S'assurer que le champ caution_type est obligatoire pour les 2A+
|
||||
if not self.object.first_year and "caution_type" in form.fields:
|
||||
form.fields["caution_type"].required = True
|
||||
form.fields["caution_type"].help_text = _("Choose how you want to pay the deposit")
|
||||
form.fields["caution_type"].widget = forms.RadioSelect(choices=form.fields["caution_type"].choices)
|
||||
# S'assurer que le champ deposit_type est obligatoire pour les 2A+
|
||||
if not self.object.first_year and "deposit_type" in form.fields:
|
||||
form.fields["deposit_type"].required = True
|
||||
form.fields["deposit_type"].help_text = _("Choose how you want to pay the deposit")
|
||||
form.fields["deposit_type"].widget = forms.RadioSelect(choices=form.fields["deposit_type"].choices)
|
||||
|
||||
return form
|
||||
|
||||
@ -850,8 +850,8 @@ class WEIUpdateRegistrationView(ProtectQuerysetMixin, LoginRequiredMixin, Update
|
||||
form.instance.information = information
|
||||
|
||||
# Sauvegarder le type de caution pour les 2A+
|
||||
if "caution_type" in form.cleaned_data:
|
||||
form.instance.caution_type = form.cleaned_data["caution_type"]
|
||||
if "deposit_type" in form.cleaned_data:
|
||||
form.instance.deposit_type = form.cleaned_data["deposit_type"]
|
||||
form.instance.save()
|
||||
|
||||
return super().form_valid(form)
|
||||
@ -957,8 +957,8 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
|
||||
# Calculer le montant total nécessaire (frais + caution si transaction)
|
||||
total_needed = fee
|
||||
if registration.caution_type == 'note':
|
||||
total_needed += registration.wei.caution_amount
|
||||
if registration.deposit_type == 'note':
|
||||
total_needed += registration.wei.deposit_amount
|
||||
context["total_needed"] = total_needed
|
||||
|
||||
form = context["form"]
|
||||
@ -988,22 +988,22 @@ 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 caution_check uniquement pour les non-première année et le rendre obligatoire
|
||||
# Ajouter le champ deposit_check uniquement pour les non-première année et le rendre obligatoire
|
||||
if not registration.first_year:
|
||||
if registration.caution_type == 'check':
|
||||
form.fields["caution_check"] = forms.BooleanField(
|
||||
if registration.deposit_type == 'check':
|
||||
form.fields["deposit_check"] = forms.BooleanField(
|
||||
required=True,
|
||||
initial=registration.caution_check,
|
||||
label=_("Caution check given"),
|
||||
initial=registration.deposit_check,
|
||||
label=_("Deposit check given"),
|
||||
help_text=_("Please make sure the check is given before validating the registration")
|
||||
)
|
||||
else:
|
||||
form.fields["caution_check"] = forms.BooleanField(
|
||||
form.fields["deposit_check"] = forms.BooleanField(
|
||||
required=True,
|
||||
initial=False,
|
||||
label=_("Create deposit transaction"),
|
||||
help_text=_("A transaction of %(amount).2f€ will be created from the user's Note account") % {
|
||||
'amount': registration.wei.caution_amount / 100
|
||||
'amount': registration.wei.deposit_amount / 100
|
||||
}
|
||||
)
|
||||
|
||||
@ -1039,8 +1039,8 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
club = registration.wei
|
||||
user = registration.user
|
||||
|
||||
if "caution_check" in form.data:
|
||||
registration.caution_check = form.data["caution_check"] == "on"
|
||||
if "deposit_check" in form.data:
|
||||
registration.deposit_check = form.data["deposit_check"] == "on"
|
||||
registration.save()
|
||||
membership = form.instance
|
||||
membership.user = user
|
||||
@ -1084,8 +1084,8 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
|
||||
# Calculer le montant total nécessaire (frais + caution si transaction)
|
||||
total_needed = fee
|
||||
if registration.caution_type == 'note':
|
||||
total_needed += club.caution_amount
|
||||
if registration.deposit_type == 'note':
|
||||
total_needed += club.deposit_amount
|
||||
|
||||
# Vérifier que l'utilisateur a assez d'argent pour tout payer
|
||||
if user.note.balance + credit_amount < total_needed:
|
||||
@ -1136,14 +1136,14 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView):
|
||||
membership.roles.add(WEIRole.objects.get(name="Adhérent⋅e WEI"))
|
||||
|
||||
# Créer la transaction de caution si nécessaire
|
||||
if registration.caution_type == 'note':
|
||||
if registration.deposit_type == 'note':
|
||||
from note.models import Transaction
|
||||
Transaction.objects.create(
|
||||
source=user.note,
|
||||
destination=club.note,
|
||||
quantity=1,
|
||||
amount=club.caution_amount,
|
||||
reason=_("Caution %(name)s") % {'name': club.name},
|
||||
amount=club.deposit_amount,
|
||||
reason=_("Deposit %(name)s") % {'name': club.name},
|
||||
valid=True,
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user