From 40ac1daece15e8d4b1d693f591ca5be394bed9c0 Mon Sep 17 00:00:00 2001 From: Ehouarn Date: Mon, 2 Jun 2025 17:51:33 +0200 Subject: [PATCH] Tests et permissions --- apps/permission/fixtures/initial.json | 4 ++-- apps/wei/tests/test_wei_registration.py | 8 ++++++++ apps/wei/views.py | 12 ++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/permission/fixtures/initial.json b/apps/permission/fixtures/initial.json index 08f88f2b..883db297 100644 --- a/apps/permission/fixtures/initial.json +++ b/apps/permission/fixtures/initial.json @@ -4694,6 +4694,7 @@ "name": "GC WEI", "permissions": [ 22, + 62, 70, 72, 76, @@ -4719,6 +4720,7 @@ 113, 128, 130, + 142, 271, 272, 273, @@ -4755,7 +4757,6 @@ 285, 286, 287, - 288, 289, 290, 291 @@ -4961,7 +4962,6 @@ 285, 286, 287, - 288, 289, 290, 291 diff --git a/apps/wei/tests/test_wei_registration.py b/apps/wei/tests/test_wei_registration.py index 7b55095b..00aab46c 100644 --- a/apps/wei/tests/test_wei_registration.py +++ b/apps/wei/tests/test_wei_registration.py @@ -126,6 +126,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, )) qs = WEIClub.objects.filter(name="Create WEI Test", year=self.year + 1) self.assertTrue(qs.exists()) @@ -160,6 +161,7 @@ class TestWEIRegistration(TestCase): membership_end="2000-09-30", date_start="2000-09-01", date_end="2000-09-03", + caution_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) @@ -318,6 +320,7 @@ class TestWEIRegistration(TestCase): bus=[], team=[], roles=[], + caution_type='check' )) self.assertEqual(response.status_code, 200) self.assertFalse(response.context["membership_form"].is_valid()) @@ -335,6 +338,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' )) qs = WEIRegistration.objects.filter(user_id=user.id) self.assertTrue(qs.exists()) @@ -354,6 +358,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' )) self.assertEqual(response.status_code, 200) self.assertTrue("This user is already registered to this WEI." in str(response.context["form"].errors)) @@ -506,6 +511,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' ) ) qs = WEIRegistration.objects.filter(user_id=self.user.id, soge_credit=False, clothing_size="M") @@ -560,6 +566,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' ) ) qs = WEIRegistration.objects.filter(user_id=self.user.id, clothing_size="L") @@ -583,6 +590,7 @@ class TestWEIRegistration(TestCase): team=[], roles=[], information_json=self.registration.information_json, + caution_type='check' ) ) self.assertFalse(response.context["membership_form"].is_valid()) diff --git a/apps/wei/views.py b/apps/wei/views.py index cb75f8f2..a880a2fa 100644 --- a/apps/wei/views.py +++ b/apps/wei/views.py @@ -1084,12 +1084,12 @@ class WEIValidateRegistrationView(ProtectQuerysetMixin, ProtectedCreateView): # Vérifier que l'utilisateur a assez d'argent pour tout payer if not registration.soge_credit and user.note.balance + credit_amount < total_needed: form.add_error('credit_type', - _("This user doesn't have enough money to join this club and pay the deposit. " - "Current balance: %(balance)d€, credit: %(credit)d€, needed: %(needed)d€") % { - 'balance': user.note.balance, - 'credit': credit_amount, - 'needed': total_needed, - }) + _("This user doesn't have enough money to join this club and pay the deposit. " + "Current balance: %(balance)d€, credit: %(credit)d€, needed: %(needed)d€") % { + 'balance': user.note.balance, + 'credit': credit_amount, + 'needed': total_needed} + ) return super().form_invalid(form) if credit_amount: