mirror of
				https://gitlab.com/animath/si/plateforme.git
				synced 2025-10-31 23:04:30 +01:00 
			
		
		
		
	Compare commits
	
		
			2 Commits
		
	
	
		
			c151ff3611
			...
			daac77ba57
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | daac77ba57 | ||
|  | 9b5ad96aaa | 
| @@ -9,7 +9,7 @@ from django.core.exceptions import ValidationError | ||||
| from django.utils import formats | ||||
| from django.utils.translation import gettext_lazy as _ | ||||
|  | ||||
| from .models import Note, Participation, Passage, Pool, Team, Tournament, Solution, Synthesis | ||||
| from .models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament | ||||
|  | ||||
|  | ||||
| class TeamForm(forms.ModelForm): | ||||
|   | ||||
| @@ -71,4 +71,4 @@ class Command(BaseCommand): | ||||
|                 sympa.subscribe(volunteer.user.email, f"jurys-{slug}", True) | ||||
|  | ||||
|         for admin in AdminRegistration.objects.all(): | ||||
|             sympa.subscribe(admin.user.email, f"admins", True) | ||||
|             sympa.subscribe(admin.user.email, "admins", True) | ||||
|   | ||||
| @@ -14,7 +14,13 @@ | ||||
|                 <dd class="col-sm-10"><a href="{% url "participation:team_detail" pk=participation.team.pk %}">{{ participation.team }}</a></dd> | ||||
|  | ||||
|                 <dt class="col-sm-2">{% trans "Tournament:" %}</dt> | ||||
|                 <dd class="col-sm-10"><a href="{% url "participation:tournament_detail" pk=participation.tournament.pk %}">{{ participation.tournament }}</a></dd> | ||||
|                 <dd class="col-sm-10"> | ||||
|                     {% if participation.tournament %} | ||||
|                         <a href="{% url "participation:tournament_detail" pk=participation.tournament.pk %}">{{ participation.tournament }}</a> | ||||
|                     {% else %} | ||||
|                         {% trans "any" %} | ||||
|                     {% endif %} | ||||
|                 </dd> | ||||
|  | ||||
|                 <dt class="col-sm-2">{% trans "Solutions:" %}</dt> | ||||
|                 <dd class="col-sm-10"> | ||||
|   | ||||
| @@ -41,8 +41,13 @@ | ||||
|             </dd> | ||||
|  | ||||
|             <dt class="col-sm-6 text-right">{% trans "Tournament:" %}</dt> | ||||
|             {% trans "any" as any %} | ||||
|             <dd class="col-sm-6"><a href="{% url "participation:tournament_detail" pk=team.participation.tournament.pk %}">{{ team.participation.tournament|default:any }}</a></dd> | ||||
|             <dd class="col-sm-6"> | ||||
|                 {% if team.participation.tournament %} | ||||
|                     <a href="{% url "participation:tournament_detail" pk=team.participation.tournament.pk %}">{{ team.participation.tournament }}</a> | ||||
|                 {% else %} | ||||
|                     {% trans "any" %} | ||||
|                 {% endif %} | ||||
|             </dd> | ||||
|  | ||||
|             <dt class="col-sm-6 text-right">{% trans "Photo authorizations:" %}</dt> | ||||
|             <dd class="col-sm-6"> | ||||
|   | ||||
| @@ -210,6 +210,8 @@ class TestStudentParticipation(TestCase): | ||||
|             email_confirmed=True, | ||||
|             team=self.team, | ||||
|             photo_authorization="authorization/photo/mai-linh", | ||||
|             health_sheet="authorization/health/mai-linh", | ||||
|             parental_authorization="authorization/parental/mai-linh", | ||||
|         ) | ||||
|  | ||||
|         third_user = User.objects.create( | ||||
| @@ -226,8 +228,34 @@ class TestStudentParticipation(TestCase): | ||||
|             email_confirmed=True, | ||||
|             team=self.team, | ||||
|             photo_authorization="authorization/photo/yohann", | ||||
|             health_sheet="authorization/health/yohann", | ||||
|             parental_authorization="authorization/parental/yohann", | ||||
|         ) | ||||
|  | ||||
|         fourth_user = User.objects.create( | ||||
|             first_name="tfjm", | ||||
|             last_name="tfjm", | ||||
|             email="tfjm@example.com", | ||||
|             password="tfjm", | ||||
|         ) | ||||
|         StudentRegistration.objects.create( | ||||
|             user=fourth_user, | ||||
|             student_class=10, | ||||
|             school="Sun", | ||||
|             give_contact_to_animath=False, | ||||
|             email_confirmed=True, | ||||
|             team=self.team, | ||||
|             photo_authorization="authorization/photo/tfjm", | ||||
|             health_sheet="authorization/health/tfjm", | ||||
|             parental_authorization="authorization/parental/tfjm", | ||||
|         ) | ||||
|  | ||||
|         self.coach.registration.team = self.team | ||||
|         self.coach.registration.health_sheet = "authorization/health/coach" | ||||
|         self.coach.registration.photo_authorization = "authorization/photo/coach" | ||||
|         self.coach.registration.email_confirmed = True | ||||
|         self.coach.registration.save() | ||||
|  | ||||
|         self.client.force_login(self.superuser) | ||||
|         # Admin users can't ask for validation | ||||
|         resp = self.client.post(reverse("participation:team_detail", args=(self.team.pk,)), data=dict( | ||||
| @@ -251,6 +279,8 @@ class TestStudentParticipation(TestCase): | ||||
|         self.assertEqual(resp.status_code, 200) | ||||
|  | ||||
|         self.user.registration.photo_authorization = "authorization/photo/ananas" | ||||
|         self.user.registration.health_sheet = "authorization/health/ananas" | ||||
|         self.user.registration.parental_authorization = "authorization/parental/ananas" | ||||
|         self.user.registration.save() | ||||
|  | ||||
|         resp = self.client.get(reverse("participation:team_detail", args=(self.team.pk,))) | ||||
|   | ||||
| @@ -4,12 +4,11 @@ | ||||
| from django.urls import path | ||||
| from django.views.generic import TemplateView | ||||
|  | ||||
| from .views import CreateTeamView, JoinTeamView, \ | ||||
|     MyParticipationDetailView, MyTeamDetailView, NoteUpdateView, ParticipationDetailView, \ | ||||
|     PassageCreateView, PassageDetailView, PassageUpdateView, PoolCreateView, PoolDetailView, \ | ||||
|     PoolUpdateView, PoolUpdateTeamsView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, \ | ||||
|     TeamUpdateView, TournamentCreateView, TournamentDetailView, TournamentListView, TournamentUpdateView, \ | ||||
|     SolutionUploadView, SynthesisUploadView | ||||
| from .views import CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, NoteUpdateView, \ | ||||
|     ParticipationDetailView, PassageCreateView, PassageDetailView, PassageUpdateView, PoolCreateView, PoolDetailView, \ | ||||
|     PoolUpdateTeamsView, PoolUpdateView, SolutionUploadView, SynthesisUploadView, TeamAuthorizationsView, \ | ||||
|     TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, TournamentCreateView, TournamentDetailView, \ | ||||
|     TournamentListView, TournamentUpdateView | ||||
|  | ||||
|  | ||||
| app_name = "participation" | ||||
|   | ||||
| @@ -9,7 +9,7 @@ from django.contrib.sites.models import Site | ||||
| from django.core.exceptions import PermissionDenied | ||||
| from django.core.mail import send_mail | ||||
| from django.db import transaction | ||||
| from django.http import HttpResponse, Http404 | ||||
| from django.http import Http404, HttpResponse | ||||
| from django.shortcuts import redirect | ||||
| from django.template.loader import render_to_string | ||||
| from django.urls import reverse_lazy | ||||
| @@ -24,9 +24,9 @@ from tfjm.matrix import Matrix | ||||
| from tfjm.views import AdminMixin, VolunteerMixin | ||||
|  | ||||
| from .forms import JoinTeamForm, NoteForm, ParticipationForm, PassageForm, PoolForm, PoolTeamsForm, \ | ||||
|     RequestValidationForm, TeamForm, TournamentForm, ValidateParticipationForm, SolutionForm, SynthesisForm | ||||
| from .models import Note, Participation, Passage, Pool, Team, Tournament, Solution, Synthesis | ||||
| from .tables import NoteTable, PassageTable, PoolTable, TeamTable, TournamentTable, ParticipationTable | ||||
|     RequestValidationForm, SolutionForm, SynthesisForm, TeamForm, TournamentForm, ValidateParticipationForm | ||||
| from .models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament | ||||
| from .tables import NoteTable, ParticipationTable, PassageTable, PoolTable, TeamTable, TournamentTable | ||||
|  | ||||
|  | ||||
| class CreateTeamView(LoginRequiredMixin, CreateView): | ||||
| @@ -434,7 +434,7 @@ class TournamentUpdateView(VolunteerMixin, UpdateView): | ||||
|     def dispatch(self, request, *args, **kwargs): | ||||
|         if not request.user.is_authenticated or not self.request.user.registration.is_admin \ | ||||
|                 and not (self.request.user.registration.is_volunteer | ||||
|                         and self.request.user.registration.organized_tournaments.all()): | ||||
|                          and self.request.user.registration.organized_tournaments.all()): | ||||
|             return self.handle_no_permission() | ||||
|         return super().dispatch(request, *args, **kwargs) | ||||
|  | ||||
|   | ||||
| @@ -129,10 +129,18 @@ class TestRegistration(TestCase): | ||||
|             role="participant", | ||||
|             student_class=12, | ||||
|             school="God", | ||||
|             birth_date="2000-01-01", | ||||
|             address="1 Rue de Rivoli, 75001 Paris, France", | ||||
|             phone_number="0123456789", | ||||
|             responsible_name="Toto", | ||||
|             responsible_phone="0123456789", | ||||
|             responsible_email="toto@example.com", | ||||
|             give_contact_to_animath=False, | ||||
|         )) | ||||
|         self.assertRedirects(response, reverse("registration:email_validation_sent"), 302, 200) | ||||
|         self.assertTrue(User.objects.filter(email="toto@example.com").exists()) | ||||
|         self.assertTrue(User.objects.filter( | ||||
|             email="toto@example.com", | ||||
|             registration__participantregistration__studentregistration__responsible_name="Toto").exists()) | ||||
|  | ||||
|         # Email is already used | ||||
|         response = self.client.post(reverse("registration:signup"), data=dict( | ||||
| @@ -144,6 +152,12 @@ class TestRegistration(TestCase): | ||||
|             role="participant", | ||||
|             student_class=12, | ||||
|             school="God", | ||||
|             birth_date="2000-01-01", | ||||
|             address="1 Rue de Rivoli, 75001 Paris, France", | ||||
|             phone_number="0123456789", | ||||
|             responsible_name="Toto", | ||||
|             responsible_phone="0123456789", | ||||
|             responsible_email="toto@example.com", | ||||
|             give_contact_to_animath=False, | ||||
|         )) | ||||
|         self.assertEqual(response.status_code, 200) | ||||
| @@ -158,6 +172,9 @@ class TestRegistration(TestCase): | ||||
|             password1="azertyuiopazertyuiop", | ||||
|             password2="azertyuiopazertyuiop", | ||||
|             role="coach", | ||||
|             birth_date="1980-01-01", | ||||
|             address="1 Rue de Rivoli, 75001 Paris, France", | ||||
|             phone_number="0123456789", | ||||
|             professional_activity="God", | ||||
|             give_contact_to_animath=True, | ||||
|         )) | ||||
| @@ -234,8 +251,11 @@ class TestRegistration(TestCase): | ||||
|         self.student.registration.save() | ||||
|  | ||||
|         for user, data in [(self.user, dict(role="Bot")), | ||||
|                            (self.student, dict(student_class=11, school="Sky")), | ||||
|                            (self.coach, dict(professional_activity="God"))]: | ||||
|                            (self.student, dict(student_class=11, school="Sky", birth_date="2001-01-01", | ||||
|                                                address="1 Rue de Rivoli, 75001 Paris, France", responsible_name="Toto", | ||||
|                                                responsible_email="toto@example.com")), | ||||
|                            (self.coach, dict(professional_activity="God", birth_date="2001-01-01", | ||||
|                                              address="1 Rue de Rivoli, 75001 Paris, France"))]: | ||||
|             response = self.client.get(reverse("registration:update_user", args=(user.pk,))) | ||||
|             self.assertEqual(response.status_code, 200) | ||||
|  | ||||
| @@ -333,7 +353,8 @@ class TestRegistration(TestCase): | ||||
|         response = self.client.get(reverse("registration:update_user", args=(self.user.pk,))) | ||||
|         self.assertEqual(response.status_code, 403) | ||||
|  | ||||
|         response = self.client.get(reverse("registration:upload_user_photo_authorization", args=(self.user.pk,))) | ||||
|         response = self.client.get(reverse("registration:upload_user_photo_authorization", | ||||
|                                            args=(self.student.registration.pk,))) | ||||
|         self.assertEqual(response.status_code, 403) | ||||
|  | ||||
|         response = self.client.get(reverse("photo_authorization", args=("inexisting-authorization",))) | ||||
|   | ||||
| @@ -17,15 +17,14 @@ from django.utils.translation import gettext_lazy as _ | ||||
| from django.views.generic import CreateView, DetailView, RedirectView, TemplateView, UpdateView, View | ||||
| from django_tables2 import SingleTableView | ||||
| from magic import Magic | ||||
|  | ||||
| from participation.models import Solution, Synthesis, Passage | ||||
| from participation.models import Passage, Solution, Synthesis | ||||
| from tfjm.tokens import email_validation_token | ||||
| from tfjm.views import AdminMixin, UserMixin, VolunteerMixin | ||||
|  | ||||
| from .forms import AddOrganizerForm, AdminRegistrationForm, CoachRegistrationForm, HealthSheetForm, \ | ||||
|     ParentalAuthorizationForm, PhotoAuthorizationForm, SignupForm, StudentRegistrationForm, UserForm, \ | ||||
|     VolunteerRegistrationForm | ||||
| from .models import Registration, StudentRegistration, ParticipantRegistration | ||||
| from .models import ParticipantRegistration, Registration, StudentRegistration | ||||
| from .tables import RegistrationTable | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,6 @@ | ||||
| # SPDX-License-Identifier: GPL-3.0-or-later | ||||
|  | ||||
| from django.contrib.auth.mixins import LoginRequiredMixin | ||||
| from django.core.exceptions import PermissionDenied | ||||
| from haystack.generic_views import SearchView | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user