Team trigrams and names are unique

This commit is contained in:
ynerant 2021-02-07 17:39:24 +01:00
parent 200848816d
commit c9067d5202
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 92 additions and 75 deletions

View File

@ -17,11 +17,22 @@ class TeamForm(forms.ModelForm):
"""
Form to create a team, with the name and the trigram,...
"""
def clean_name(self):
if "name" in self.cleaned_data:
name = self.cleaned_data["name"].upper()
if not self.instance.pk and Team.objects.filter(name=name).exists():
raise ValidationError(_("This name is already used."))
return name
def clean_trigram(self):
trigram = self.cleaned_data["trigram"].upper()
if not re.match("[A-Z]{3}", trigram):
raise ValidationError(_("The trigram must be composed of three uppercase letters."))
return trigram
if "trigram" in self.cleaned_data:
trigram = self.cleaned_data["trigram"].upper()
if not re.match("[A-Z]{3}", trigram):
raise ValidationError(_("The trigram must be composed of three uppercase letters."))
if not self.instance.pk and Team.objects.filter(trigram=trigram).exists():
raise ValidationError(_("This trigram is already used."))
return trigram
class Meta:
model = Team

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-01-23 21:55+0100\n"
"POT-Creation-Date: 2021-02-07 17:38+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -104,51 +104,59 @@ msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
msgid "valid"
msgstr "valide"
#: apps/participation/forms.py:23 apps/participation/models.py:41
#: apps/participation/forms.py:24
msgid "This name is already used."
msgstr "Ce nom est déjà utilisé."
#: apps/participation/forms.py:31 apps/participation/models.py:41
msgid "The trigram must be composed of three uppercase letters."
msgstr "Le trigramme doit être composé de trois lettres majuscules."
#: apps/participation/forms.py:38
#: apps/participation/forms.py:34
msgid "This trigram is already used."
msgstr "Ce trigramme est déjà utilisé."
#: apps/participation/forms.py:49
msgid "No team was found with this access code."
msgstr "Aucune équipe n'a été trouvée avec ce code d'accès."
#: apps/participation/forms.py:67 apps/participation/forms.py:202
#: apps/registration/forms.py:116 apps/registration/forms.py:138
#: apps/registration/forms.py:160 apps/registration/forms.py:214
#: apps/participation/forms.py:78 apps/participation/forms.py:213
#: apps/registration/forms.py:117 apps/registration/forms.py:139
#: apps/registration/forms.py:161 apps/registration/forms.py:215
msgid "The uploaded file size must be under 2 Mo."
msgstr "Le fichier envoyé doit peser moins de 2 Mo."
#: apps/participation/forms.py:69 apps/registration/forms.py:118
#: apps/registration/forms.py:140 apps/registration/forms.py:162
#: apps/registration/forms.py:216
#: apps/participation/forms.py:80 apps/registration/forms.py:119
#: apps/registration/forms.py:141 apps/registration/forms.py:163
#: apps/registration/forms.py:217
msgid "The uploaded file must be a PDF, PNG of JPEG file."
msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG."
#: apps/participation/forms.py:87
#: apps/participation/forms.py:98
msgid "I engage myself to participate to the whole TFJM²."
msgstr "Je m'engage à participer à l'intégralité du TFJM²."
#: apps/participation/forms.py:102
#: apps/participation/forms.py:113
msgid "Message to address to the team:"
msgstr "Message à adresser à l'équipe :"
#: apps/participation/forms.py:139
#: apps/participation/forms.py:150
msgid "The uploaded file size must be under 5 Mo."
msgstr "Le fichier envoyé doit peser moins de 5 Mo."
#: apps/participation/forms.py:141 apps/participation/forms.py:204
#: apps/participation/forms.py:152 apps/participation/forms.py:215
msgid "The uploaded file must be a PDF file."
msgstr "Le fichier envoyé doit être au format PDF."
#: apps/participation/forms.py:145
#: apps/participation/forms.py:156
msgid "The PDF file must not have more than 30 pages."
msgstr "Le fichier PDF ne doit pas avoir plus de 30 pages."
#: apps/participation/forms.py:185
#: apps/participation/forms.py:196
msgid "The defender, the opponent and the reporter must be different."
msgstr "Le défenseur, l'opposant et le rapporteur doivent être différents."
#: apps/participation/forms.py:189
#: apps/participation/forms.py:200
msgid "This defender did not work on this problem."
msgstr "Ce défenseur ne travaille pas sur ce problème."
@ -506,12 +514,12 @@ msgstr ""
#: apps/participation/templates/participation/create_team.html:11
#: apps/participation/templates/participation/tournament_form.html:14
#: tfjm/templates/base.html:240
#: tfjm/templates/base.html:234
msgid "Create"
msgstr "Créer"
#: apps/participation/templates/participation/join_team.html:11
#: tfjm/templates/base.html:235
#: tfjm/templates/base.html:229
msgid "Join"
msgstr "Rejoindre"
@ -529,8 +537,7 @@ msgstr "Rejoindre"
#: apps/registration/templates/registration/payment_form.html:49
#: apps/registration/templates/registration/update_user.html:16
#: apps/registration/templates/registration/user_detail.html:153
#: apps/registration/templates/registration/user_detail.html:162
#: apps/registration/templates/registration/user_detail.html:190
#: apps/registration/templates/registration/user_detail.html:185
msgid "Update"
msgstr "Modifier"
@ -586,10 +593,10 @@ msgstr "Envoyer une solution"
#: apps/registration/templates/registration/upload_health_sheet.html:17
#: apps/registration/templates/registration/upload_parental_authorization.html:17
#: apps/registration/templates/registration/upload_photo_authorization.html:18
#: apps/registration/templates/registration/user_detail.html:163
#: apps/registration/templates/registration/user_detail.html:168
#: apps/registration/templates/registration/user_detail.html:173
#: apps/registration/templates/registration/user_detail.html:178
#: apps/registration/templates/registration/user_detail.html:183
msgid "Upload"
msgstr "Téléverser"
@ -824,8 +831,8 @@ msgid ""
"Your team must be composed of 4 members and a coach and each member must "
"upload their authorizations and confirm its email address."
msgstr ""
"Votre équipe doit être composée d'au moins 4 membres et un encadrant et chaque "
"membre doit envoyer ses autorisations et confirmé son adresse e-mail."
"Votre équipe doit être composée d'au moins 4 membres et un encadrant et "
"chaque membre doit envoyer ses autorisations et confirmé son adresse e-mail."
#: apps/participation/templates/participation/team_detail.html:146
msgid "This team didn't ask for validation yet."
@ -852,7 +859,7 @@ msgid "Invalidate"
msgstr "Invalider"
#: apps/participation/templates/participation/team_detail.html:169
#: apps/participation/views.py:323
#: apps/participation/views.py:324
msgid "Upload motivation letter"
msgstr "Envoyer la lettre de motivation"
@ -861,7 +868,7 @@ msgid "Update team"
msgstr "Modifier l'équipe"
#: apps/participation/templates/participation/team_detail.html:179
#: apps/participation/views.py:424
#: apps/participation/views.py:425
msgid "Leave team"
msgstr "Quitter l'équipe"
@ -870,7 +877,7 @@ msgid "Are you sure that you want to leave this team?"
msgstr "Êtes-vous sûr·e de vouloir quitter cette équipe ?"
#: apps/participation/templates/participation/team_list.html:6
#: tfjm/templates/base.html:228
#: tfjm/templates/base.html:222
msgid "All teams"
msgstr "Toutes les équipes"
@ -953,7 +960,7 @@ msgid "Add pool"
msgstr "Ajouter une poule"
#: apps/participation/templates/participation/tournament_list.html:6
#: tfjm/templates/base.html:224
#: tfjm/templates/base.html:218
msgid "All tournaments"
msgstr "Tous les tournois"
@ -966,7 +973,7 @@ msgid "Back to the team detail"
msgstr "Retour aux détails de l'utilisateur"
#: apps/participation/views.py:43 tfjm/templates/base.html:74
#: tfjm/templates/base.html:239
#: tfjm/templates/base.html:233
msgid "Create team"
msgstr "Créer une équipe"
@ -979,16 +986,16 @@ msgid "You are already in a team."
msgstr "Vous êtes déjà dans une équipe."
#: apps/participation/views.py:88 tfjm/templates/base.html:79
#: tfjm/templates/base.html:234
#: tfjm/templates/base.html:228
msgid "Join team"
msgstr "Rejoindre une équipe"
#: apps/participation/views.py:150 apps/participation/views.py:430
#: apps/participation/views.py:463
#: apps/participation/views.py:150 apps/participation/views.py:431
#: apps/participation/views.py:464
msgid "You are not in a team."
msgstr "Vous n'êtes pas dans une équipe."
#: apps/participation/views.py:151 apps/participation/views.py:464
#: apps/participation/views.py:151 apps/participation/views.py:465
msgid "You don't participate, so you don't have any team."
msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe."
@ -1016,98 +1023,98 @@ msgstr ""
"d'adresse e-mail, soit une autorisation, soit des personnes, soit la lettre "
"de motivation, soit le tournoi n'a pas été choisi."
#: apps/participation/views.py:239
#: apps/participation/views.py:240
msgid "You are not an organizer of the tournament."
msgstr "Vous n'êtes pas un organisateur du tournoi."
#: apps/participation/views.py:242
#: apps/participation/views.py:243
msgid "This team has no pending validation."
msgstr "L'équipe n'a pas de validation en attente."
#: apps/participation/views.py:272
#: apps/participation/views.py:273
msgid "You must specify if you validate the registration or not."
msgstr "Vous devez spécifier si vous validez l'inscription ou non."
#: apps/participation/views.py:303
#: apps/participation/views.py:304
#, python-brace-format
msgid "Update team {trigram}"
msgstr "Mise à jour de l'équipe {trigram}"
#: apps/participation/views.py:361 apps/participation/views.py:410
#: apps/participation/views.py:362 apps/participation/views.py:411
#, python-brace-format
msgid "Motivation letter of {team}.{ext}"
msgstr "Lettre de motivation de {team}.{ext}"
#: apps/participation/views.py:391
#: apps/participation/views.py:392
#, python-brace-format
msgid "Photo authorization of {participant}.{ext}"
msgstr "Autorisation de droit à l'image de {participant}.{ext}"
#: apps/participation/views.py:397
#: apps/participation/views.py:398
#, python-brace-format
msgid "Parental authorization of {participant}.{ext}"
msgstr "Autorisation parentale de {participant}.{ext}"
#: apps/participation/views.py:404
#: apps/participation/views.py:405
#, python-brace-format
msgid "Health sheet of {participant}.{ext}"
msgstr "Fiche sanitaire de {participant}.{ext}"
#: apps/participation/views.py:414
#: apps/participation/views.py:415
#, python-brace-format
msgid "Photo authorizations of team {trigram}.zip"
msgstr "Autorisations de droit à l'image de l'équipe {trigram}.zip"
#: apps/participation/views.py:432
#: apps/participation/views.py:433
msgid "The team is already validated or the validation is pending."
msgstr "La validation de l'équipe est déjà faite ou en cours."
#: apps/participation/views.py:478
#: apps/participation/views.py:479
msgid "The team is not validated yet."
msgstr "L'équipe n'est pas encore validée."
#: apps/participation/views.py:490
#: apps/participation/views.py:491
#, python-brace-format
msgid "Participation of team {trigram}"
msgstr "Participation de l'équipe {trigram}"
#: apps/participation/views.py:579
#: apps/participation/views.py:580
msgid "You can't upload a solution after the deadline."
msgstr "Vous ne pouvez pas envoyer de solution après la date limite."
#: apps/participation/views.py:760
#: apps/participation/views.py:761
msgid "You can't upload a synthesis after the deadline."
msgstr "Vous ne pouvez pas envoyer de note de synthèse après la date limite."
#: apps/registration/forms.py:21 apps/registration/forms.py:53
#: apps/registration/forms.py:22 apps/registration/forms.py:54
msgid "role"
msgstr "rôle"
#: apps/registration/forms.py:23
#: apps/registration/forms.py:24
msgid "participant"
msgstr "participant"
#: apps/registration/forms.py:24 apps/registration/models.py:259
#: apps/registration/forms.py:25 apps/registration/models.py:259
msgid "coach"
msgstr "encadrant"
#: apps/registration/forms.py:34 apps/registration/forms.py:67
#: apps/registration/forms.py:35 apps/registration/forms.py:68
msgid "This email address is already used."
msgstr "Cette adresse e-mail est déjà utilisée."
#: apps/registration/forms.py:55 apps/registration/models.py:285
#: apps/registration/forms.py:56 apps/registration/models.py:285
msgid "volunteer"
msgstr "bénévole"
#: apps/registration/forms.py:56 apps/registration/models.py:304
#: apps/registration/forms.py:57 apps/registration/models.py:304
msgid "admin"
msgstr "admin"
#: apps/registration/forms.py:208
#: apps/registration/forms.py:209
msgid "Pending"
msgstr "En attente"
#: apps/registration/forms.py:224
#: apps/registration/forms.py:225
msgid "You must upload your scholarship attestation."
msgstr "Vous devez envoyer votre attestation de bourse."
@ -1407,8 +1414,8 @@ msgid "Your password has been set. You may go ahead and log in now."
msgstr "Votre mot de passe a été changé. Vous pouvez désormais vous connecter."
#: apps/registration/templates/registration/password_reset_complete.html:10
#: tfjm/templates/base.html:127 tfjm/templates/base.html:244
#: tfjm/templates/base.html:245 tfjm/templates/registration/login.html:7
#: tfjm/templates/base.html:127 tfjm/templates/base.html:238
#: tfjm/templates/base.html:239 tfjm/templates/registration/login.html:7
#: tfjm/templates/registration/login.html:8
#: tfjm/templates/registration/login.html:25
msgid "Log in"
@ -1645,7 +1652,7 @@ msgid "valid:"
msgstr "valide :"
#: apps/registration/templates/registration/user_detail.html:136
#: apps/registration/templates/registration/user_detail.html:189
#: apps/registration/templates/registration/user_detail.html:184
msgid "Update payment"
msgstr "Modifier le paiement"
@ -1657,22 +1664,18 @@ msgstr "Télécharger l'attestation de bourse"
msgid "Impersonate"
msgstr "Impersonifier"
#: apps/registration/templates/registration/user_detail.html:161
msgid "Update user"
msgstr "Modifier l'utilisateur"
#: apps/registration/templates/registration/user_detail.html:167
#: apps/registration/templates/registration/user_detail.html:162
#: apps/registration/views.py:313
msgid "Upload photo authorization"
msgstr "Téléverser l'autorisation de droit à l'image"
#: apps/registration/templates/registration/user_detail.html:172
#: apps/registration/templates/registration/user_detail.html:167
#: apps/registration/views.py:334
msgid "Upload health sheet"
msgstr "Téléverser la fiche sanitaire"
#: apps/registration/templates/registration/user_detail.html:172
#: apps/registration/templates/registration/user_detail.html:177
#: apps/registration/templates/registration/user_detail.html:182
#: apps/registration/views.py:355
msgid "Upload parental authorization"
msgstr "Téléverser l'autorisation parentale"
@ -1711,22 +1714,22 @@ msgstr "Détails de l'utilisateur {user}"
msgid "Update user {user}"
msgstr "Mise à jour de l'utilisateur {user}"
#: apps/registration/views.py:459
#: apps/registration/views.py:461
#, python-brace-format
msgid "Photo authorization of {student}.{ext}"
msgstr "Autorisation de droit à l'image de {student}.{ext}"
#: apps/registration/views.py:482
#: apps/registration/views.py:484
#, python-brace-format
msgid "Health sheet of {student}.{ext}"
msgstr "Fiche sanitaire de {student}.{ext}"
#: apps/registration/views.py:505
#: apps/registration/views.py:507
#, python-brace-format
msgid "Parental authorization of {student}.{ext}"
msgstr "Autorisation parentale de {student}.{ext}"
#: apps/registration/views.py:527
#: apps/registration/views.py:529
#, python-brace-format
msgid "Scholarship attestation of {user}.{ext}"
msgstr "Notification de bourse de {user}.{ext}"
@ -1851,15 +1854,15 @@ msgstr ""
"avez reçu par mail. Vous pouvez renvoyer un mail en cliquant sur <a href="
"\"%(send_email_url)s\">ce lien</a>."
#: tfjm/templates/base.html:189
#: tfjm/templates/base.html:183
msgid "Contact us"
msgstr "Nous contacter"
#: tfjm/templates/base.html:208
#: tfjm/templates/base.html:202
msgid "About"
msgstr "À propos"
#: tfjm/templates/base.html:231
#: tfjm/templates/base.html:225
msgid "Search results"
msgstr "Résultats de la recherche"
@ -1895,3 +1898,6 @@ msgstr "Résultats"
#: tfjm/templates/search/search.html:25
msgid "No results found."
msgstr "Aucun résultat."
#~ msgid "Update user"
#~ msgstr "Modifier l'utilisateur"