mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 03:58:26 +02:00
Send validation emails to all local organizers
This commit is contained in:
@ -6,7 +6,7 @@
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Bonjour {{ user.registration }},
|
||||
Bonjour,
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
@ -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².
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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."))
|
||||
|
Reference in New Issue
Block a user