From e026f49f8d51a5ac553c5bd4d7eb75f1fbf2cec5 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Fri, 7 Jun 2024 17:20:06 +0200 Subject: [PATCH] Add parental and photo authorizations + make health and vaccine sheet and motivation letter optional Signed-off-by: Emmy D'Anello --- .../commands/create_chat_channels.py | 3 +- .../management/commands/export_results.py | 3 +- .../management/commands/export_solutions.py | 2 +- .../commands/generate_seconds_sheet.py | 2 +- participation/models.py | 18 +-- .../templates/participation/team_detail.html | 88 ++++++++------ registration/models.py | 11 +- .../tex/parental_authorization_eteam.tex | 66 +++++++++++ .../tex/photo_authorization_eteam_adult.tex | 112 ++++++++++++++++++ .../templates/registration/user_detail.html | 62 +++++----- registration/views.py | 25 +++- tfjm/context_processors.py | 3 + tfjm/settings.py | 9 ++ 13 files changed, 316 insertions(+), 88 deletions(-) create mode 100644 registration/templates/registration/tex/parental_authorization_eteam.tex create mode 100644 registration/templates/registration/tex/photo_authorization_eteam_adult.tex diff --git a/chat/management/commands/create_chat_channels.py b/chat/management/commands/create_chat_channels.py index ea2a343..bf31934 100644 --- a/chat/management/commands/create_chat_channels.py +++ b/chat/management/commands/create_chat_channels.py @@ -1,6 +1,7 @@ # Copyright (C) 2024 by Animath # SPDX-License-Identifier: GPL-3.0-or-later +from django.conf import settings from django.core.management import BaseCommand from django.utils.translation import activate from participation.models import Team, Tournament @@ -18,7 +19,7 @@ class Command(BaseCommand): help = "Create chat channels for tournaments and teams." def handle(self, *args, **kwargs): - activate('fr') + activate(settings.PREFERRED_LANGUAGE_CODE) # Création de canaux généraux, d'annonces, d'aide jurys et orgas, etc. # Le canal d'annonces est accessibles à tous⋅tes, mais seul⋅es les admins peuvent y écrire. diff --git a/participation/management/commands/export_results.py b/participation/management/commands/export_results.py index 2cf4d04..8924b69 100644 --- a/participation/management/commands/export_results.py +++ b/participation/management/commands/export_results.py @@ -1,6 +1,7 @@ # Copyright (C) 2021 by Animath # SPDX-License-Identifier: GPL-3.0-or-later +from django.conf import settings from django.core.management import BaseCommand from django.utils.formats import date_format from django.utils.translation import activate @@ -9,7 +10,7 @@ from participation.models import Tournament class Command(BaseCommand): def handle(self, *args, **kwargs): - activate('fr') + activate(settings.PREFERRED_LANGUAGE_CODE) tournaments = Tournament.objects.order_by('-date_start', 'name') for tournament in tournaments: diff --git a/participation/management/commands/export_solutions.py b/participation/management/commands/export_solutions.py index c4a15d2..a97c315 100644 --- a/participation/management/commands/export_solutions.py +++ b/participation/management/commands/export_solutions.py @@ -11,7 +11,7 @@ from participation.models import Solution, Tournament class Command(BaseCommand): def handle(self, *args, **kwargs): - activate('fr') + activate(settings.PROBLEMS) base_dir = Path(__file__).parent.parent.parent.parent base_dir /= "output" diff --git a/participation/management/commands/generate_seconds_sheet.py b/participation/management/commands/generate_seconds_sheet.py index 38959c4..436f81a 100644 --- a/participation/management/commands/generate_seconds_sheet.py +++ b/participation/management/commands/generate_seconds_sheet.py @@ -12,7 +12,7 @@ from ...models import Passage, Tournament class Command(BaseCommand): def handle(self, *args, **options): - activate('fr') + activate(settings.PREFERRED_LANGUAGE_CODE) gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT) try: spreadsheet = gc.open("Tableau des deuxièmes", folder_id=settings.NOTES_DRIVE_FOLDER_ID) diff --git a/participation/models.py b/participation/models.py index 88860c1..64d77d8 100644 --- a/participation/models.py +++ b/participation/models.py @@ -81,12 +81,12 @@ class Team(models.Model): return False if any(not r.photo_authorization for r in self.participants.all()): return False - if not self.motivation_letter: + if settings.MOTIVATION_LETTER_REQUIRED and not self.motivation_letter: return False if not self.participation.tournament.remote: - if any(r.under_18 and not r.health_sheet for r in self.students.all()): + if settings.HEALTH_SHEET_REQUIRED and any(r.under_18 and not r.health_sheet for r in self.students.all()): return False - if any(r.under_18 and not r.vaccine_sheet for r in self.students.all()): + if settings.VACCINE_SHEET_REQUIRED and any(r.under_18 and not r.vaccine_sheet for r in self.students.all()): return False if any(r.under_18 and not r.parental_authorization for r in self.students.all()): return False @@ -119,7 +119,7 @@ class Team(models.Model): 'content': content, }) - if not self.motivation_letter: + if settings.MOTIVATION_LETTER_REQUIRED and not self.motivation_letter: text = _("The team {trigram} has not uploaded a motivation letter. " "You can upload your motivation letter using this link.") url = reverse_lazy("participation:upload_team_motivation_letter", args=(self.pk,)) @@ -458,7 +458,7 @@ class Tournament(models.Model): self.save() def update_ranking_spreadsheet(self): # noqa: C901 - translation.activate('fr') + translation.activate(settings.PREFERRED_LANGUAGE_CODE) gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT) spreadsheet = gc.open_by_key(self.notes_sheet_id) @@ -1101,7 +1101,7 @@ class Pool(models.Model): return super().validate_constraints() def update_spreadsheet(self): # noqa: C901 - translation.activate('fr') + translation.activate(settings.PREFERRED_LANGUAGE_CODE) # Create tournament sheet if it does not exist self.tournament.create_spreadsheet() @@ -1446,7 +1446,7 @@ class Pool(models.Model): worksheet.client.batch_update(spreadsheet.id, body) def update_juries_lines_spreadsheet(self): - translation.activate('fr') + translation.activate(settings.PREFERRED_LANGUAGE_CODE) gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT) spreadsheet = gc.open_by_key(self.tournament.notes_sheet_id) @@ -1467,7 +1467,7 @@ class Pool(models.Model): max_row += 1 def parse_spreadsheet(self): - translation.activate('fr') + translation.activate(settings.PREFERRED_LANGUAGE_CODE) gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT) self.tournament.create_spreadsheet() @@ -1837,7 +1837,7 @@ class Note(models.Model): if not self.has_any_note(): return - translation.activate('fr') + translation.activate(settings.PREFERRED_LANGUAGE_CODE) gc = gspread.service_account_from_dict(settings.GOOGLE_SERVICE_CLIENT) passage = Passage.objects.prefetch_related('pool__tournament', 'pool__participations').get(pk=self.passage.pk) diff --git a/participation/templates/participation/team_detail.html b/participation/templates/participation/team_detail.html index 4e12bb0..7e6ad0f 100644 --- a/participation/templates/participation/team_detail.html +++ b/participation/templates/participation/team_detail.html @@ -73,32 +73,36 @@ {% endif %} - {% if not team.participation.tournament.remote %} -
{% trans "Health sheets:" %}
-
- {% for student in team.students.all %} - {% if student.under_18 %} - {% if student.health_sheet %} - {{ student }}{% if not forloop.last %},{% endif %} - {% else %} - {{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %} + {% if not team.participation.tournament.remote %} + {% if TFJM.HEALTH_SHEET_REQUIRED %} +
{% trans "Health sheets:" %}
+
+ {% for student in team.students.all %} + {% if student.under_18 %} + {% if student.health_sheet %} + {{ student }}{% if not forloop.last %},{% endif %} + {% else %} + {{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %} + {% endif %} {% endif %} - {% endif %} - {% endfor %} -
+ {% endfor %} + + {% endif %} -
{% trans "Vaccine sheets:" %}
-
- {% for student in team.students.all %} - {% if student.under_18 %} - {% if student.vaccine_sheet %} - {{ student }}{% if not forloop.last %},{% endif %} - {% else %} - {{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %} + {% if TFJM.VACCINE_SHEET_REQUIRED %} +
{% trans "Vaccine sheets:" %}
+
+ {% for student in team.students.all %} + {% if student.under_18 %} + {% if student.vaccine_sheet %} + {{ student }}{% if not forloop.last %},{% endif %} + {% else %} + {{ student }} ({% trans "Not uploaded yet" %}){% if not forloop.last %},{% endif %} + {% endif %} {% endif %} - {% endif %} - {% endfor %} -
+ {% endfor %} + + {% endif %}
{% trans "Parental authorizations:" %}
@@ -129,17 +133,19 @@ {% endif %} {% endif %} -
{% trans "Motivation letter:" %}
-
- {% if team.motivation_letter %} - {% trans "Download" %} - {% else %} - {% trans "Not uploaded yet" %} - {% endif %} - {% if user.registration.team == team and not user.registration.team.participation.valid or user.registration.is_admin %} - - {% endif %} -
+ {% if TFJM.MOTIVATION_LETTER_REQUIRED %} +
{% trans "Motivation letter:" %}
+
+ {% if team.motivation_letter %} + {% trans "Download" %} + {% else %} + {% trans "Not uploaded yet" %} + {% endif %} + {% if user.registration.team == team and not user.registration.team.participation.valid or user.registration.is_admin %} + + {% endif %} +
+ {% endif %} {% if user.registration.is_volunteer %} {% if user.registration in self.team.participation.tournament.organizers or user.registration.is_admin %} @@ -234,10 +240,12 @@ {% endif %} {% endif %} - {% trans "Upload motivation letter" as modal_title %} - {% trans "Upload" as modal_button %} - {% url "participation:upload_team_motivation_letter" pk=team.pk as modal_action %} - {% include "base_modal.html" with modal_id="uploadMotivationLetter" modal_enctype="multipart/form-data" %} + {% if TFJM.MOTIVATION_LETTER_REQUIRED %} + {% trans "Upload motivation letter" as modal_title %} + {% trans "Upload" as modal_button %} + {% url "participation:upload_team_motivation_letter" pk=team.pk as modal_action %} + {% include "base_modal.html" with modal_id="uploadMotivationLetter" modal_enctype="multipart/form-data" %} + {% endif %} {% trans "Update team" as modal_title %} {% trans "Update" as modal_button %} @@ -253,7 +261,9 @@ {% block extrajavascript %}