diff --git a/apps/participation/templates/participation/mails/request_validation.html b/apps/participation/templates/participation/mails/request_validation.html
index 0f280fb..cbf75d1 100644
--- a/apps/participation/templates/participation/mails/request_validation.html
+++ b/apps/participation/templates/participation/mails/request_validation.html
@@ -6,7 +6,7 @@
-Bonjour {{ user.registration }},
+Bonjour,
diff --git a/apps/participation/templates/participation/mails/request_validation.txt b/apps/participation/templates/participation/mails/request_validation.txt
index f68a12c..d9ff5bf 100644
--- a/apps/participation/templates/participation/mails/request_validation.txt
+++ b/apps/participation/templates/participation/mails/request_validation.txt
@@ -1,4 +1,4 @@
-Bonjour {{ user.registration }},
+Bonjour {{ user }},
L'équipe « {{ team.name }} » ({{ team.trigram }}) vient de demander à valider son équipe pour participer
au {{ team.participation.get_problem_display }} du TFJM².
diff --git a/apps/participation/tests.py b/apps/participation/tests.py
index a54d054..a0c4610 100644
--- a/apps/participation/tests.py
+++ b/apps/participation/tests.py
@@ -321,8 +321,12 @@ class TestStudentParticipation(TestCase):
A team asked for validation. Try to validate it.
"""
self.team.participation.valid = False
+ self.team.participation.tournament = self.tournament
self.team.participation.save()
+ self.tournament.organizers.add(self.superuser.registration)
+ self.tournament.save()
+
# No right to do that
resp = self.client.post(reverse("participation:team_detail", args=(self.team.pk,)), data=dict(
_form_type="ValidateParticipationForm",
@@ -384,6 +388,9 @@ class TestStudentParticipation(TestCase):
self.coach.registration.team = self.team
self.coach.registration.save()
+ self.team.participation.tournament = self.tournament
+ self.team.participation.save()
+
response = self.client.get(reverse("participation:update_team", args=(self.team.pk,)))
self.assertEqual(response.status_code, 200)
diff --git a/apps/participation/views.py b/apps/participation/views.py
index 90daffb..2672467 100644
--- a/apps/participation/views.py
+++ b/apps/participation/views.py
@@ -5,6 +5,7 @@ from io import BytesIO
import os
from zipfile import ZipFile
+from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.sites.models import Site
from django.core.exceptions import PermissionDenied
@@ -20,7 +21,7 @@ from django.views.generic import CreateView, DetailView, FormView, RedirectView,
from django.views.generic.edit import FormMixin, ProcessFormView
from django_tables2 import SingleTableView
from magic import Magic
-from registration.models import AdminRegistration, StudentRegistration
+from registration.models import StudentRegistration
from tfjm.lists import get_sympa_client
from tfjm.matrix import Matrix
from tfjm.views import AdminMixin, VolunteerMixin
@@ -221,19 +222,21 @@ class TeamDetailView(LoginRequiredMixin, FormMixin, ProcessFormView, DetailView)
self.object.participation.valid = False
self.object.participation.save()
- for admin in AdminRegistration.objects.all():
- mail_context = dict(user=admin.user, team=self.object, domain=Site.objects.first().domain)
- mail_plain = render_to_string("participation/mails/request_validation.txt", mail_context)
- mail_html = render_to_string("participation/mails/request_validation.html", mail_context)
- admin.user.email_user("[TFJM²] Validation d'équipe", mail_plain, html_message=mail_html)
+ mail_context = dict(team=self.object, domain=Site.objects.first().domain)
+ mail_plain = render_to_string("participation/mails/request_validation.txt", mail_context)
+ mail_html = render_to_string("participation/mails/request_validation.html", mail_context)
+ send_mail("[TFJM²] Validation d'équipe", mail_plain, [settings.DEFAULT_FROM_EMAIL],
+ [self.object.participation.tournament.organizers_email], html_message=mail_html)
+
return super().form_valid(form)
def handle_validate_participation(self, form):
"""
An admin validates the team (or not)
"""
- if not self.request.user.registration.is_admin:
- form.add_error(None, _("You are not an administrator."))
+ if not self.object.participation.tournament \
+ or self.request.user.registration not in self.object.participation.tournament.organizers.all():
+ form.add_error(None, _("You are not an organizer of the tournament."))
return self.form_invalid(form)
elif self.object.participation.valid is not False:
form.add_error(None, _("This team has no pending validation."))
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index eadea53..4400d06 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-01-23 19:56+0100\n"
+"POT-Creation-Date: 2021-01-23 21:33+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO \n"
"Language-Team: LANGUAGE \n"
@@ -852,7 +852,7 @@ msgid "Invalidate"
msgstr "Invalider"
#: apps/participation/templates/participation/team_detail.html:169
-#: apps/participation/views.py:320
+#: apps/participation/views.py:323
msgid "Upload motivation letter"
msgstr "Envoyer la lettre de motivation"
@@ -861,7 +861,7 @@ msgid "Update team"
msgstr "Modifier l'équipe"
#: apps/participation/templates/participation/team_detail.html:179
-#: apps/participation/views.py:421
+#: apps/participation/views.py:424
msgid "Leave team"
msgstr "Quitter l'équipe"
@@ -965,49 +965,49 @@ msgstr "Ajouter un tournoi"
msgid "Back to the team detail"
msgstr "Retour aux détails de l'utilisateur"
-#: apps/participation/views.py:42 tfjm/templates/base.html:74
+#: apps/participation/views.py:43 tfjm/templates/base.html:74
#: tfjm/templates/base.html:239
msgid "Create team"
msgstr "Créer une équipe"
-#: apps/participation/views.py:51 apps/participation/views.py:96
+#: apps/participation/views.py:52 apps/participation/views.py:97
msgid "You don't participate, so you can't create a team."
msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe."
-#: apps/participation/views.py:53 apps/participation/views.py:98
+#: apps/participation/views.py:54 apps/participation/views.py:99
msgid "You are already in a team."
msgstr "Vous êtes déjà dans une équipe."
-#: apps/participation/views.py:87 tfjm/templates/base.html:79
+#: apps/participation/views.py:88 tfjm/templates/base.html:79
#: tfjm/templates/base.html:234
msgid "Join team"
msgstr "Rejoindre une équipe"
-#: apps/participation/views.py:149 apps/participation/views.py:427
-#: apps/participation/views.py:460
+#: apps/participation/views.py:150 apps/participation/views.py:430
+#: apps/participation/views.py:463
msgid "You are not in a team."
msgstr "Vous n'êtes pas dans une équipe."
-#: apps/participation/views.py:150 apps/participation/views.py:461
+#: apps/participation/views.py:151 apps/participation/views.py:464
msgid "You don't participate, so you don't have any team."
msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe."
-#: apps/participation/views.py:174
+#: apps/participation/views.py:175
#, python-brace-format
msgid "Detail of team {trigram}"
msgstr "Détails de l'équipe {trigram}"
-#: apps/participation/views.py:211
+#: apps/participation/views.py:212
msgid "You don't participate, so you can't request the validation of the team."
msgstr ""
"Vous ne participez pas, vous ne pouvez pas demander la validation de "
"l'équipe."
-#: apps/participation/views.py:214
+#: apps/participation/views.py:215
msgid "The validation of the team is already done or pending."
msgstr "La validation de l'équipe est déjà faite ou en cours."
-#: apps/participation/views.py:217
+#: apps/participation/views.py:218
msgid ""
"The team can't be validated: missing email address confirmations, "
"authorizations, people, motivation letter or the tournament is not set."
@@ -1016,66 +1016,66 @@ 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:236
-msgid "You are not an administrator."
-msgstr "Vous n'êtes pas administrateur."
-
#: apps/participation/views.py:239
+msgid "You are not an organizer of the tournament."
+msgstr "Vous n'êtes pas un organisateur du tournoi."
+
+#: apps/participation/views.py:242
msgid "This team has no pending validation."
msgstr "L'équipe n'a pas de validation en attente."
-#: apps/participation/views.py:269
+#: apps/participation/views.py:272
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:300
+#: apps/participation/views.py:303
#, python-brace-format
msgid "Update team {trigram}"
msgstr "Mise à jour de l'équipe {trigram}"
-#: apps/participation/views.py:358 apps/participation/views.py:407
+#: apps/participation/views.py:361 apps/participation/views.py:410
#, python-brace-format
msgid "Motivation letter of {team}.{ext}"
msgstr "Lettre de motivation de {team}.{ext}"
-#: apps/participation/views.py:388
+#: apps/participation/views.py:391
#, python-brace-format
msgid "Photo authorization of {participant}.{ext}"
msgstr "Autorisation de droit à l'image de {participant}.{ext}"
-#: apps/participation/views.py:394
+#: apps/participation/views.py:397
#, python-brace-format
msgid "Parental authorization of {participant}.{ext}"
msgstr "Autorisation parentale de {participant}.{ext}"
-#: apps/participation/views.py:401
+#: apps/participation/views.py:404
#, python-brace-format
msgid "Health sheet of {participant}.{ext}"
msgstr "Fiche sanitaire de {participant}.{ext}"
-#: apps/participation/views.py:411
+#: apps/participation/views.py:414
#, 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:429
+#: apps/participation/views.py:432
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:475
+#: apps/participation/views.py:478
msgid "The team is not validated yet."
msgstr "L'équipe n'est pas encore validée."
-#: apps/participation/views.py:487
+#: apps/participation/views.py:490
#, python-brace-format
msgid "Participation of team {trigram}"
msgstr "Participation de l'équipe {trigram}"
-#: apps/participation/views.py:576
+#: apps/participation/views.py:579
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:757
+#: apps/participation/views.py:760
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."
@@ -1880,5 +1880,8 @@ msgstr "Résultats"
msgid "No results found."
msgstr "Aucun résultat."
+#~ msgid "You are not an administrator."
+#~ msgstr "Vous n'êtes pas administrateur."
+
#~ msgid "The code of the form xxx-xxx-xxx at the end of the BBB link."
#~ msgstr "Le code de la forme xxx-xxx-xxx à la fin du lien BBB."