1
0
mirror of https://gitlab.com/animath/si/plateforme.git synced 2024-12-04 19:26:54 +00:00

Prevent registration when we are not between registration dates

Signed-off-by: Emmy D'Anello <emmy.danello@animath.fr>
This commit is contained in:
Emmy D'Anello 2024-10-28 20:21:02 +01:00
parent 9de8a2ed0e
commit fe399c869d
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
4 changed files with 145 additions and 70 deletions

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: TFJM\n" "Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-09 13:22+0200\n" "POT-Creation-Date: 2024-10-28 20:14+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Emmy D'Anello <emmy.danello@animath.fr>\n" "Last-Translator: Emmy D'Anello <emmy.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -217,7 +217,7 @@ msgstr ""
msgid "Toggle fullscreen mode" msgid "Toggle fullscreen mode"
msgstr "Inverse le mode plein écran" msgstr "Inverse le mode plein écran"
#: chat/templates/chat/content.html:76 tfjm/templates/navbar.html:125 #: chat/templates/chat/content.html:76 tfjm/templates/navbar.html:126
msgid "Log out" msgid "Log out"
msgstr "Déconnexion" msgstr "Déconnexion"
@ -244,14 +244,14 @@ msgid "ETEAM Chat"
msgstr "Chat de l'ETEAM" msgstr "Chat de l'ETEAM"
#: chat/templates/chat/login.html:10 chat/templates/chat/login.html:12 #: chat/templates/chat/login.html:10 chat/templates/chat/login.html:12
#: chat/urls.py:13 tfjm/templates/navbar.html:74 #: chat/urls.py:13 tfjm/templates/navbar.html:72
msgid "Chat" msgid "Chat"
msgstr "Chat" msgstr "Chat"
#: chat/templates/chat/login.html:10 chat/templates/chat/login.html:36 #: chat/templates/chat/login.html:10 chat/templates/chat/login.html:36
#: registration/templates/registration/password_reset_complete.html:10 #: registration/templates/registration/password_reset_complete.html:10
#: tfjm/templates/base.html:89 tfjm/templates/base.html:90 #: tfjm/templates/base.html:89 tfjm/templates/base.html:90
#: tfjm/templates/navbar.html:106 #: tfjm/templates/navbar.html:107
#: tfjm/templates/registration/includes/login.html:22 #: tfjm/templates/registration/includes/login.html:22
#: tfjm/templates/registration/login.html:7 #: tfjm/templates/registration/login.html:7
#: tfjm/templates/registration/login.html:8 #: tfjm/templates/registration/login.html:8
@ -269,7 +269,7 @@ msgstr "équipes"
msgid "round" msgid "round"
msgstr "tour" msgstr "tour"
#: draw/apps.py:10 draw/consumers.py:1042 tfjm/templates/navbar.html:68 #: draw/apps.py:10 draw/consumers.py:1042 tfjm/templates/navbar.html:66
msgid "Draw" msgid "Draw"
msgstr "Tirage au sort" msgstr "Tirage au sort"
@ -311,7 +311,7 @@ msgstr "Le tirage au sort du tournoi {tournament} va commencer."
#: draw/consumers.py:256 draw/consumers.py:282 draw/consumers.py:692 #: draw/consumers.py:256 draw/consumers.py:282 draw/consumers.py:692
#: draw/consumers.py:910 draw/consumers.py:1000 draw/consumers.py:1022 #: draw/consumers.py:910 draw/consumers.py:1000 draw/consumers.py:1022
#: draw/consumers.py:1125 draw/templates/draw/tournament_content.html:5 #: draw/consumers.py:1124 draw/templates/draw/tournament_content.html:5
msgid "The draw has not started yet." msgid "The draw has not started yet."
msgstr "Le tirage au sort n'a pas encore commencé." msgstr "Le tirage au sort n'a pas encore commencé."
@ -446,9 +446,9 @@ msgid ""
"from the ranking of the first round, in order to mix the teams between the " "from the ranking of the first round, in order to mix the teams between the "
"two days." "two days."
msgstr "" msgstr ""
"Le tirage au sort du tour {round} commence. L'ordre de passage est déterminé à " "Le tirage au sort du tour {round} commence. L'ordre de passage est déterminé "
"partir du classement du premier tour, afin de mélanger les équipes entre les " "à partir du classement du premier tour, afin de mélanger les équipes entre "
"deux jours." "les deux jours."
#: draw/consumers.py:1034 #: draw/consumers.py:1034
#, python-brace-format #, python-brace-format
@ -456,8 +456,8 @@ msgid ""
"The draw of the round {round} is starting. The passage order is another time " "The draw of the round {round} is starting. The passage order is another time "
"randomly drawn." "randomly drawn."
msgstr "" msgstr ""
"Le tirage au sort du tour {round} commence. L'ordre de passage est à nouveau tiré " "Le tirage au sort du tour {round} commence. L'ordre de passage est à nouveau "
"au hasard." "tiré au hasard."
#: draw/consumers.py:1043 #: draw/consumers.py:1043
msgid "The draw of the second round is starting!" msgid "The draw of the second round is starting!"
@ -1034,18 +1034,18 @@ msgid "The team is already validated or the validation is pending."
msgstr "La validation de l'équipe est déjà faite ou en cours." msgstr "La validation de l'équipe est déjà faite ou en cours."
#: participation/forms.py:94 participation/forms.py:367 #: participation/forms.py:94 participation/forms.py:367
#: registration/forms.py:126 registration/forms.py:148 #: registration/forms.py:141 registration/forms.py:163
#: registration/forms.py:170 registration/forms.py:192 #: registration/forms.py:185 registration/forms.py:207
#: registration/forms.py:214 registration/forms.py:236 #: registration/forms.py:229 registration/forms.py:251
#: registration/forms.py:295 registration/forms.py:328 #: registration/forms.py:310 registration/forms.py:343
msgid "The uploaded file size must be under 2 Mo." msgid "The uploaded file size must be under 2 Mo."
msgstr "Le fichier envoyé doit peser moins de 2 Mo." msgstr "Le fichier envoyé doit peser moins de 2 Mo."
#: participation/forms.py:96 registration/forms.py:128 #: participation/forms.py:96 registration/forms.py:143
#: registration/forms.py:150 registration/forms.py:172 #: registration/forms.py:165 registration/forms.py:187
#: registration/forms.py:194 registration/forms.py:216 #: registration/forms.py:209 registration/forms.py:231
#: registration/forms.py:238 registration/forms.py:297 #: registration/forms.py:253 registration/forms.py:312
#: registration/forms.py:330 #: registration/forms.py:345
msgid "The uploaded file must be a PDF, PNG of JPEG file." msgid "The uploaded file must be a PDF, PNG of JPEG file."
msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG." msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG."
@ -2509,7 +2509,7 @@ msgid "Edit tournament"
msgstr "Modifier le tournoi" msgstr "Modifier le tournoi"
#: participation/templates/participation/tournament_detail.html:80 #: participation/templates/participation/tournament_detail.html:80
#: tfjm/templates/navbar.html:37 #: tfjm/templates/navbar.html:35
msgid "Teams" msgid "Teams"
msgstr "Équipes" msgstr "Équipes"
@ -2652,7 +2652,7 @@ msgid "Warning: non-free format"
msgstr "Attention : format non libre" msgstr "Attention : format non libre"
#: participation/views.py:62 tfjm/templates/base.html:84 #: participation/views.py:62 tfjm/templates/base.html:84
#: tfjm/templates/navbar.html:43 #: tfjm/templates/navbar.html:41
msgid "Create team" msgid "Create team"
msgstr "Créer une équipe" msgstr "Créer une équipe"
@ -2665,7 +2665,7 @@ msgid "You are already in a team."
msgstr "Vous êtes déjà dans une équipe." msgstr "Vous êtes déjà dans une équipe."
#: participation/views.py:103 tfjm/templates/base.html:79 #: participation/views.py:103 tfjm/templates/base.html:79
#: tfjm/templates/navbar.html:48 #: tfjm/templates/navbar.html:46
msgid "Join team" msgid "Join team"
msgstr "Rejoindre une équipe" msgstr "Rejoindre une équipe"
@ -2898,27 +2898,50 @@ msgstr "Marquer comme en attente"
msgid "Mark as invalid" msgid "Mark as invalid"
msgstr "Marquer comme invalide" msgstr "Marquer comme invalide"
#: registration/forms.py:23 #: registration/forms.py:25
msgid "role" msgid "role"
msgstr "rôle" msgstr "rôle"
#: registration/forms.py:25 #: registration/forms.py:27
msgid "participant" msgid "participant"
msgstr "participant⋅e" msgstr "participant⋅e"
#: registration/forms.py:26 registration/models.py:516 #: registration/forms.py:28 registration/models.py:516
msgid "coach" msgid "coach"
msgstr "encadrant⋅e" msgstr "encadrant⋅e"
#: registration/forms.py:36 registration/forms.py:61 registration/forms.py:92 #: registration/forms.py:38 registration/forms.py:76 registration/forms.py:107
msgid "This email address is already used." msgid "This email address is already used."
msgstr "Cette adresse e-mail est déjà utilisée." msgstr "Cette adresse e-mail est déjà utilisée."
#: registration/forms.py:286 #: registration/forms.py:45
#, fuzzy
#| msgid ""
#| "Registrations for the tournament of {tournament} are ending on the {date:"
#| "%Y-%m-%d %H:%M}."
msgid ""
"Registrations are not opened yet. They will open on the {opening_date:%Y-%m-"
"%d %H:%M}."
msgstr ""
"Les inscriptions pour le tournoi de {tournament} se terminent le {date:%d/%m/"
"%Y %H:%M}."
#: registration/forms.py:49
#, fuzzy
#| msgid ""
#| "Registrations for the tournament of {tournament} are ending on the {date:"
#| "%Y-%m-%d %H:%M}."
msgid ""
"Registrations for this year are closed since {opening_date:%Y-%m-%d %H:%M}."
msgstr ""
"Les inscriptions pour le tournoi de {tournament} se terminent le {date:%d/%m/"
"%Y %H:%M}."
#: registration/forms.py:301
msgid "Pending" msgid "Pending"
msgstr "En attente" msgstr "En attente"
#: registration/forms.py:305 registration/forms.py:338 #: registration/forms.py:320 registration/forms.py:353
msgid "You must upload your receipt." msgid "You must upload your receipt."
msgstr "Vous devez envoyer votre justificatif." msgstr "Vous devez envoyer votre justificatif."
@ -3909,15 +3932,37 @@ msgstr ""
#: registration/templates/registration/signup.html:5 #: registration/templates/registration/signup.html:5
#: registration/templates/registration/signup.html:12 #: registration/templates/registration/signup.html:12
#: registration/templates/registration/signup.html:26 registration/views.py:48 #: registration/templates/registration/signup.html:39 registration/views.py:48
msgid "Sign up" msgid "Sign up"
msgstr "Inscription" msgstr "Inscription"
#: registration/templates/registration/signup.html:21 #: registration/templates/registration/signup.html:17
msgid ""
"Thank you for your great interest, but registrations are not opened yet!"
msgstr ""
"Merci pour votre grand intérêt, mais les inscriptions ne sont pas encore ouvertes !"
#: registration/templates/registration/signup.html:18
msgid "They will open on:"
msgstr "Elles ouvriront le :"
#: registration/templates/registration/signup.html:19
msgid "Please come back at this time to register!"
msgstr "Merci de revenir à ce moment-là pour vous inscrire !"
#: registration/templates/registration/signup.html:23
msgid "Registrations are closed for this year. We hope to see you next year!"
msgstr "Les inscriptions sont closes pour cette année. Nous espérons vous revoir l'année prochaine !"
#: registration/templates/registration/signup.html:24
msgid "If needed, you can contact us by mail."
msgstr "Si nécessaire, vous pouvez nous contacter par mail."
#: registration/templates/registration/signup.html:34
msgid "By registering, you certify that you have read and accepted our" msgid "By registering, you certify that you have read and accepted our"
msgstr "En vous inscrivant, vous certifiez avoir lu et accepté notre" msgstr "En vous inscrivant, vous certifiez avoir lu et accepté notre"
#: registration/templates/registration/signup.html:22 #: registration/templates/registration/signup.html:35
msgid "privacy policy" msgid "privacy policy"
msgstr "politique de confidentialité" msgstr "politique de confidentialité"
@ -4274,11 +4319,11 @@ msgstr "Privé, réservé aux utilisateur⋅rices explicitement autorisé⋅es"
msgid "Admin users" msgid "Admin users"
msgstr "Administrateur⋅rices" msgstr "Administrateur⋅rices"
#: tfjm/settings.py:173 #: tfjm/settings.py:174
msgid "English" msgid "English"
msgstr "Anglais" msgstr "Anglais"
#: tfjm/settings.py:174 #: tfjm/settings.py:175
msgid "French" msgid "French"
msgstr "Français" msgstr "Français"
@ -4521,39 +4566,39 @@ msgstr ""
"Si vous ne finalisez pas votre inscription avant la date limite indiquée, " "Si vous ne finalisez pas votre inscription avant la date limite indiquée, "
"vous ne pourrez malheureusement pas participer au 𝕋𝔽𝕁𝕄²." "vous ne pourrez malheureusement pas participer au 𝕋𝔽𝕁𝕄²."
#: tfjm/templates/navbar.html:19 tfjm/urls.py:34 #: tfjm/templates/navbar.html:17 tfjm/urls.py:33
msgid "Home" msgid "Home"
msgstr "Accueil" msgstr "Accueil"
#: tfjm/templates/navbar.html:24 #: tfjm/templates/navbar.html:22
msgid "Tournament" msgid "Tournament"
msgstr "Tournoi" msgstr "Tournoi"
#: tfjm/templates/navbar.html:28 #: tfjm/templates/navbar.html:26
msgid "Tournaments" msgid "Tournaments"
msgstr "Tournois" msgstr "Tournois"
#: tfjm/templates/navbar.html:34 #: tfjm/templates/navbar.html:32
msgid "Users" msgid "Users"
msgstr "Utilisateur⋅rices" msgstr "Utilisateur⋅rices"
#: tfjm/templates/navbar.html:54 #: tfjm/templates/navbar.html:52
msgid "My team" msgid "My team"
msgstr "Mon équipe" msgstr "Mon équipe"
#: tfjm/templates/navbar.html:59 #: tfjm/templates/navbar.html:57
msgid "My participation" msgid "My participation"
msgstr "Ma participation" msgstr "Ma participation"
#: tfjm/templates/navbar.html:80 #: tfjm/templates/navbar.html:78
msgid "Administration" msgid "Administration"
msgstr "Administration" msgstr "Administration"
#: tfjm/templates/navbar.html:88 #: tfjm/templates/navbar.html:86
msgid "Search…" msgid "Search…"
msgstr "Chercher…" msgstr "Chercher…"
#: tfjm/templates/navbar.html:97 #: tfjm/templates/navbar.html:95
msgid "Return to admin view" msgid "Return to admin view"
msgstr "Retourner à l'interface administrateur⋅rice" msgstr "Retourner à l'interface administrateur⋅rice"
@ -4561,7 +4606,7 @@ msgstr "Retourner à l'interface administrateur⋅rice"
msgid "Register" msgid "Register"
msgstr "S'inscrire" msgstr "S'inscrire"
#: tfjm/templates/navbar.html:118 #: tfjm/templates/navbar.html:119
msgid "My account" msgid "My account"
msgstr "Mon compte" msgstr "Mon compte"

View File

@ -1,5 +1,6 @@
# Copyright (C) 2020 by Animath # Copyright (C) 2020 by Animath
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
from datetime import datetime
from django import forms from django import forms
from django.conf import settings from django.conf import settings
@ -7,6 +8,7 @@ from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.forms import FileInput from django.forms import FileInput
from django.utils.text import format_lazy
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from .models import CoachRegistration, ParticipantRegistration, Payment, \ from .models import CoachRegistration, ParticipantRegistration, Payment, \
@ -36,6 +38,19 @@ class SignupForm(UserCreationForm):
self.add_error("email", _("This email address is already used.")) self.add_error("email", _("This email address is already used."))
return email return email
def clean(self):
# Check that registrations are opened
now = datetime.now()
if now < settings.REGISTRATION_DATES['open']:
self.add_error(None, format_lazy(_("Registrations are not opened yet. "
"They will open on the {opening_date:%Y-%m-%d %H:%M}."),
opening_date=settings.REGISTRATION_DATES['open']))
elif now > settings.REGISTRATION_DATES['close']:
self.add_error(None, format_lazy(_("Registrations for this year are closed since "
"{opening_date:%Y-%m-%d %H:%M}."),
opening_date=settings.REGISTRATION_DATES['close']))
return super().clean()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["first_name"].required = True self.fields["first_name"].required = True

View File

@ -9,30 +9,42 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h2>{% trans "Sign up" %}</h2> {% now "c" as now %}
{% if now < TFJM.REGISTRATION_DATES.open.isoformat %}
<form method="post"> <div class="alert alert-warning">
{% csrf_token %} {% trans "Thank you for your great interest, but registrations are not opened yet!" %}
{{ form|crispy }} {% trans "They will open on:" %} {{ TFJM.REGISTRATION_DATES.open|date:'DATETIME_FORMAT' }}.
<div id="registration_form"></div> {% trans "Please come back at this time to register!" %}
<div class="py-2 text-muted">
<i class="fas fa-info-circle"></i>
{% trans "By registering, you certify that you have read and accepted our" %}
<a href="{% url 'about' %}#politique-confidentialite">{% trans "privacy policy" %}</a>.
</div> </div>
{% elif now > TFJM.REGISTRATION_DATES.close.isoformat %}
<div class="alert alert-danger">
{% trans "Registrations are closed for this year. We hope to see you next year!" %}
{% trans "If needed, you can contact us by mail." %}
</div>
{% else %}
<form method="post">
{% csrf_token %}
{{ form|crispy }}
<div id="registration_form"></div>
<button class="btn btn-success" type="submit"> <div class="py-2 text-muted">
{% trans "Sign up" %} <i class="fas fa-info-circle"></i>
</button> {% trans "By registering, you certify that you have read and accepted our" %}
</form> <a href="{% url 'about' %}#politique-confidentialite">{% trans "privacy policy" %}</a>.
</div>
<div id="student_registration_form" class="d-none"> <button class="btn btn-success" type="submit">
{{ student_registration_form|crispy }} {% trans "Sign up" %}
</div> </button>
<div id="coach_registration_form" class="d-none"> </form>
{{ coach_registration_form|crispy }}
</div> <div id="student_registration_form" class="d-none">
{{ student_registration_form|crispy }}
</div>
<div id="coach_registration_form" class="d-none">
{{ coach_registration_form|crispy }}
</div>
{% endif %}
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}

View File

@ -96,9 +96,12 @@
</li> </li>
{% endif %} {% endif %}
{% if not user.is_authenticated %} {% if not user.is_authenticated %}
<li class="nav-item active"> {% now "c" as now %}
<a class="nav-link" href="{% url "registration:signup" %}"><i class="fas fa-user-plus"></i> {% trans "Register" %}</a> {% if TFJM.REGISTRATION_DATES.open.isoformat <= now and now <= TFJM.REGISTRATION_DATES.close.isoformat %}
</li> <li class="nav-item active">
<a class="nav-link" href="{% url "registration:signup" %}"><i class="fas fa-user-plus"></i> {% trans "Register" %}</a>
</li>
{% endif %}
<li class="nav-item active"> <li class="nav-item active">
<a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#loginModal"> <a class="nav-link" href="#" data-bs-toggle="modal" data-bs-target="#loginModal">
<i class="fas fa-sign-in-alt"></i> {% trans "Log in" %} <i class="fas fa-sign-in-alt"></i> {% trans "Log in" %}