mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-14 22:07:31 +02:00
Correction des tests et autres
This commit is contained in:
parent
63f6528adc
commit
6822500fdc
@ -1,10 +1,11 @@
|
|||||||
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
# Copyright (C) 2018-2025 by BDE ENS Paris-Saclay
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
|
||||||
from .registration import WEIForm, WEIRegistrationForm, WEIMembership1AForm, WEIMembershipForm, BusForm, BusTeamForm
|
from .registration import WEIForm, WEIRegistrationForm, WEIRegistration1AForm, WEIRegistration2AForm, WEIMembership1AForm, \
|
||||||
|
WEIMembershipForm, BusForm, BusTeamForm
|
||||||
from .surveys import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, CurrentSurvey
|
from .surveys import WEISurvey, WEISurveyInformation, WEISurveyAlgorithm, CurrentSurvey
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'WEIForm', 'WEIRegistrationForm', 'WEIMembership1AForm', 'WEIMembershipForm', 'BusForm', 'BusTeamForm',
|
'WEIForm', 'WEIRegistrationForm', 'WEIRegistration1AForm', 'WEIRegistration2AForm', 'WEIMembership1AForm', 'WEIMembershipForm', 'BusForm', 'BusTeamForm',
|
||||||
'WEISurvey', 'WEISurveyInformation', 'WEISurveyAlgorithm', 'CurrentSurvey',
|
'WEISurvey', 'WEISurveyInformation', 'WEISurveyAlgorithm', 'CurrentSurvey',
|
||||||
]
|
]
|
||||||
|
@ -43,7 +43,7 @@ class WEIRegistrationForm(forms.ModelForm):
|
|||||||
fields = [
|
fields = [
|
||||||
'user', 'soge_credit', 'birth_date', 'gender', 'clothing_size',
|
'user', 'soge_credit', 'birth_date', 'gender', 'clothing_size',
|
||||||
'health_issues', 'emergency_contact_name', 'emergency_contact_phone',
|
'health_issues', 'emergency_contact_name', 'emergency_contact_phone',
|
||||||
'first_year', 'information_json', 'caution_check', 'caution_type'
|
'first_year', 'information_json', 'caution_check'
|
||||||
]
|
]
|
||||||
widgets = {
|
widgets = {
|
||||||
"user": Autocomplete(
|
"user": Autocomplete(
|
||||||
@ -61,10 +61,23 @@ class WEIRegistrationForm(forms.ModelForm):
|
|||||||
"caution_check": forms.BooleanField(
|
"caution_check": forms.BooleanField(
|
||||||
required=False,
|
required=False,
|
||||||
),
|
),
|
||||||
"caution_type": forms.RadioSelect(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class WEIRegistration2AForm(WEIRegistrationForm):
|
||||||
|
class Meta(WEIRegistrationForm.Meta):
|
||||||
|
fields = WEIRegistrationForm.Meta.fields + ['caution_type']
|
||||||
|
widgets = WEIRegistrationForm.Meta.widgets.copy()
|
||||||
|
widgets.update({
|
||||||
|
"caution_type": forms.RadioSelect(),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
class WEIRegistration1AForm(WEIRegistrationForm):
|
||||||
|
class Meta(WEIRegistrationForm.Meta):
|
||||||
|
fields = WEIRegistrationForm.Meta.fields
|
||||||
|
|
||||||
|
|
||||||
class WEIChooseBusForm(forms.Form):
|
class WEIChooseBusForm(forms.Form):
|
||||||
bus = forms.ModelMultipleChoiceField(
|
bus = forms.ModelMultipleChoiceField(
|
||||||
queryset=Bus.objects,
|
queryset=Bus.objects,
|
||||||
|
@ -337,7 +337,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
emergency_contact_phone='+33123456789',
|
emergency_contact_phone='+33123456789',
|
||||||
bus=[self.bus.id],
|
bus=[self.bus.id],
|
||||||
team=[self.team.id],
|
team=[self.team.id],
|
||||||
roles=[role.id for role in WEIRole.objects.filter(~Q(name="1A")).all()],
|
roles=[role.id for role in WEIRole.objects.filter(~Q(name="1A") & ~Q(name="GC WEI")).all()],
|
||||||
caution_type='check'
|
caution_type='check'
|
||||||
))
|
))
|
||||||
qs = WEIRegistration.objects.filter(user_id=user.id)
|
qs = WEIRegistration.objects.filter(user_id=user.id)
|
||||||
@ -632,7 +632,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
second_bus = Bus.objects.create(wei=self.wei, name="Second bus")
|
second_bus = Bus.objects.create(wei=self.wei, name="Second bus")
|
||||||
second_team = BusTeam.objects.create(bus=second_bus, name="Second team", color=42)
|
second_team = BusTeam.objects.create(bus=second_bus, name="Second team", color=42)
|
||||||
response = self.client.post(reverse("wei:validate_registration", kwargs=dict(pk=self.registration.pk)), dict(
|
response = self.client.post(reverse("wei:validate_registration", kwargs=dict(pk=self.registration.pk)), dict(
|
||||||
roles=[WEIRole.objects.get(name="GC WEI").id],
|
roles=[WEIRole.objects.get(name="Adhérent⋅e WEI").id],
|
||||||
bus=self.bus.pk,
|
bus=self.bus.pk,
|
||||||
team=second_team.pk,
|
team=second_team.pk,
|
||||||
credit_type=4, # Bank transfer
|
credit_type=4, # Bank transfer
|
||||||
@ -647,7 +647,7 @@ class TestWEIRegistration(TestCase):
|
|||||||
self.assertTrue("This team doesn't belong to the given bus." in str(response.context["form"].errors))
|
self.assertTrue("This team doesn't belong to the given bus." in str(response.context["form"].errors))
|
||||||
|
|
||||||
response = self.client.post(reverse("wei:validate_registration", kwargs=dict(pk=self.registration.pk)), dict(
|
response = self.client.post(reverse("wei:validate_registration", kwargs=dict(pk=self.registration.pk)), dict(
|
||||||
roles=[WEIRole.objects.get(name="GC WEI").id],
|
roles=[WEIRole.objects.get(name="Adhérent⋅e WEI").id],
|
||||||
bus=self.bus.pk,
|
bus=self.bus.pk,
|
||||||
team=self.team.pk,
|
team=self.team.pk,
|
||||||
credit_type=4, # Bank transfer
|
credit_type=4, # Bank transfer
|
||||||
|
@ -35,7 +35,7 @@ from permission.views import ProtectQuerysetMixin, ProtectedCreateView
|
|||||||
|
|
||||||
from .forms.registration import WEIChooseBusForm
|
from .forms.registration import WEIChooseBusForm
|
||||||
from .models import WEIClub, WEIRegistration, WEIMembership, Bus, BusTeam, WEIRole
|
from .models import WEIClub, WEIRegistration, WEIMembership, Bus, BusTeam, WEIRole
|
||||||
from .forms import WEIForm, WEIRegistrationForm, BusForm, BusTeamForm, WEIMembership1AForm, \
|
from .forms import WEIForm, WEIRegistrationForm, WEIRegistration1AForm, WEIRegistration2AForm, BusForm, BusTeamForm, WEIMembership1AForm, \
|
||||||
WEIMembershipForm, CurrentSurvey
|
WEIMembershipForm, CurrentSurvey
|
||||||
from .tables import BusRepartitionTable, BusTable, BusTeamTable, WEITable, WEIRegistrationTable, \
|
from .tables import BusRepartitionTable, BusTable, BusTeamTable, WEITable, WEIRegistrationTable, \
|
||||||
WEIRegistration1ATable, WEIMembershipTable
|
WEIRegistration1ATable, WEIMembershipTable
|
||||||
@ -510,7 +510,7 @@ class WEIRegister1AView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
Register a new user to the WEI
|
Register a new user to the WEI
|
||||||
"""
|
"""
|
||||||
model = WEIRegistration
|
model = WEIRegistration
|
||||||
form_class = WEIRegistrationForm
|
form_class = WEIRegistration1AForm
|
||||||
extra_context = {"title": _("Register first year student to the WEI")}
|
extra_context = {"title": _("Register first year student to the WEI")}
|
||||||
|
|
||||||
def get_sample_object(self):
|
def get_sample_object(self):
|
||||||
@ -604,7 +604,7 @@ class WEIRegister2AView(ProtectQuerysetMixin, ProtectedCreateView):
|
|||||||
Register an old user to the WEI
|
Register an old user to the WEI
|
||||||
"""
|
"""
|
||||||
model = WEIRegistration
|
model = WEIRegistration
|
||||||
form_class = WEIRegistrationForm
|
form_class = WEIRegistration2AForm
|
||||||
extra_context = {"title": _("Register old student to the WEI")}
|
extra_context = {"title": _("Register old student to the WEI")}
|
||||||
|
|
||||||
def get_sample_object(self):
|
def get_sample_object(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user