1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2025-11-17 10:57:50 +01:00

Add responsabilities of accompanying coaches + translate message about pending dates

This commit is contained in:
Maxime JUST
2025-11-11 19:34:42 +01:00
parent af60d27402
commit 27a4bdf98e
4 changed files with 244 additions and 152 deletions

View File

@@ -251,7 +251,18 @@ class CoachRegistrationForm(forms.ModelForm):
"""
A coach can tell its professional activity.
"""
ACCOMPANYING_CONFIRM_CHOICES = [
("presence", _("I undertake to be present throughout the entire tournament weekend alongside the team (including overnight stays).")),
("rules", _("I undertake to respond to the team's (non-mathematical) problems and not to hesitate to discuss them with the tournament organisers, who will be able to help.")),
("cancelling", _("In case of absence, I undertake to notify the organisers as soon as possible, providing a replacement if possible.")),
]
confirm_accompanying = forms.MultipleChoiceField(
required=False,
widget=forms.CheckboxSelectMultiple,
choices=ACCOMPANYING_CONFIRM_CHOICES,
label=_("Responsabilities of accompanying coaches")
)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not settings.SUGGEST_ANIMATH:
@@ -259,9 +270,21 @@ class CoachRegistrationForm(forms.ModelForm):
class Meta:
model = CoachRegistration
fields = ('team', 'is_scientific_coach', 'is_accompanying_coach', 'gender', 'address', 'zip_code', 'city', 'country', 'phone_number',
fields = ('team', 'is_scientific_coach', 'is_accompanying_coach', 'confirm_accompanying', 'gender', 'address', 'zip_code', 'city', 'country', 'phone_number',
'last_degree', 'professional_activity', 'health_issues', 'housing_constraints',
'give_contact_to_animath', 'email_confirmed')
def clean(self):
cleaned = super().clean()
if cleaned.get("is_accompanying_coach"):
selected = set(cleaned.get("confirm_accompanying") or [])
required = {key for key, _ in self.ACCOMPANYING_CONFIRM_CHOICES}
if selected != required:
self.add_error(
"confirm_accompanying",
_("Please tick all the required confirmations."),
)
return cleaned
class VolunteerRegistrationForm(forms.ModelForm):

View File

@@ -51,15 +51,33 @@
<script>
document.addEventListener('DOMContentLoaded', () => {
let role_elem = document.getElementById("id_role")
function setup_requirements() {
const main = document.getElementById('id_is_accompanying_coach');
const group = document.getElementById('div_id_confirm_accompanying');
function toggle(){
if(main.checked) {
group.style.display = "block";
} else {
group.style.display = "none";
}
}
main.addEventListener('change', toggle);
toggle();
}
function updateView () {
let selected_role = role_elem.options[role_elem.selectedIndex].value
if (selected_role === "participant")
document.getElementById("registration_form").innerHTML = document.getElementById("student_registration_form").innerHTML
else
document.getElementById("registration_form").innerHTML = document.getElementById("coach_registration_form").innerHTML
setup_requirements();
}
role_elem.addEventListener('change', updateView)
updateView()
})
</script>
{% endblock %}