diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 13a370c..0773190 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: 2024-03-24 22:21+0100\n" +"POT-Creation-Date: 2024-03-26 23:52+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Emmy D'Anello \n" "Language-Team: LANGUAGE \n" @@ -76,9 +76,9 @@ msgstr "Le tirage a commencé !" msgid "The draw for the tournament {tournament} will start." msgstr "Le tirage au sort du tournoi {tournament} va commencer." -#: draw/consumers.py:240 draw/consumers.py:266 draw/consumers.py:676 -#: draw/consumers.py:893 draw/consumers.py:982 draw/consumers.py:1000 -#: draw/consumers.py:1090 draw/templates/draw/tournament_content.html:5 +#: draw/consumers.py:240 draw/consumers.py:266 draw/consumers.py:674 +#: draw/consumers.py:891 draw/consumers.py:980 draw/consumers.py:998 +#: draw/consumers.py:1088 draw/templates/draw/tournament_content.html:5 msgid "The draw has not started yet." msgstr "Le tirage au sort n'a pas encore commencé." @@ -87,8 +87,8 @@ msgstr "Le tirage au sort n'a pas encore commencé." msgid "The draw for the tournament {tournament} is aborted." msgstr "Le tirage au sort du tournoi {tournament} est annulé." -#: draw/consumers.py:293 draw/consumers.py:314 draw/consumers.py:611 -#: draw/consumers.py:681 draw/consumers.py:898 +#: draw/consumers.py:293 draw/consumers.py:314 draw/consumers.py:609 +#: draw/consumers.py:679 draw/consumers.py:896 msgid "This is not the time for this." msgstr "Ce n'est pas le moment pour cela." @@ -106,7 +106,7 @@ msgid "Dices from teams {teams} are identical. Please relaunch your dices." msgstr "" "Les dés des équipes {teams} sont identiques. Merci de relancer vos dés." -#: draw/consumers.py:1003 +#: draw/consumers.py:1001 msgid "This is only available for the final tournament." msgstr "Cela n'est possible que pour la finale." @@ -377,8 +377,8 @@ msgstr "Êtes-vous sûr·e de vouloir annuler le tirage au sort ?" msgid "Close" msgstr "Fermer" -#: draw/views.py:31 participation/views.py:156 participation/views.py:442 -#: participation/views.py:473 +#: draw/views.py:31 participation/views.py:155 participation/views.py:469 +#: participation/views.py:500 msgid "You are not in a team." msgstr "Vous n'êtes pas dans une équipe." @@ -474,75 +474,74 @@ msgstr "rapporteur⋅e" msgid "problem" msgstr "numéro de problème" -#: participation/forms.py:32 +#: participation/forms.py:30 msgid "This name is already used." msgstr "Ce nom est déjà utilisé." -#: participation/forms.py:39 participation/models.py:39 +#: participation/forms.py:37 participation/models.py:39 msgid "The trigram must be composed of three uppercase letters." msgstr "Le trigramme doit être composé de trois lettres majuscules." -#: participation/forms.py:42 +#: participation/forms.py:40 msgid "This trigram is already used." msgstr "Ce trigramme est déjà utilisé." -#: participation/forms.py:57 +#: participation/forms.py:55 msgid "No team was found with this access code." msgstr "Aucune équipe n'a été trouvée avec ce code d'accès." -#: participation/forms.py:61 participation/views.py:444 +#: participation/forms.py:59 participation/views.py:471 msgid "The team is already validated or the validation is pending." msgstr "La validation de l'équipe est déjà faite ou en cours." -#: participation/forms.py:90 participation/forms.py:360 +#: participation/forms.py:88 participation/forms.py:358 #: registration/forms.py:122 registration/forms.py:144 #: registration/forms.py:166 registration/forms.py:188 #: registration/forms.py:237 registration/forms.py:270 msgid "The uploaded file size must be under 2 Mo." msgstr "Le fichier envoyé doit peser moins de 2 Mo." -#: participation/forms.py:92 registration/forms.py:124 +#: participation/forms.py:90 registration/forms.py:124 #: registration/forms.py:146 registration/forms.py:168 #: registration/forms.py:190 registration/forms.py:239 #: registration/forms.py:272 msgid "The uploaded file must be a PDF, PNG of JPEG file." msgstr "Le fichier envoyé doit être au format PDF, PNG ou JPEG." -#: participation/forms.py:110 +#: participation/forms.py:108 msgid "I engage myself to participate to the whole TFJM²." msgstr "Je m'engage à participer à l'intégralité du TFJM²." -#: participation/forms.py:125 +#: participation/forms.py:123 msgid "Message to address to the team:" msgstr "Message à adresser à l'équipe :" -#: participation/forms.py:160 +#: participation/forms.py:158 msgid "The uploaded file size must be under 5 Mo." msgstr "Le fichier envoyé doit peser moins de 5 Mo." -#: participation/forms.py:162 participation/forms.py:362 +#: participation/forms.py:160 participation/forms.py:360 msgid "The uploaded file must be a PDF file." msgstr "Le fichier envoyé doit être au format PDF." -#: participation/forms.py:166 +#: participation/forms.py:164 msgid "The PDF file must not have more than 30 pages." msgstr "Le fichier PDF ne doit pas avoir plus de 30 pages." -#: participation/forms.py:238 +#: participation/forms.py:236 #: participation/templates/participation/pool_detail.html:123 -#: participation/templates/participation/tournament_detail.html:139 msgid "Add" msgstr "Ajouter" -#: participation/forms.py:253 +#: participation/forms.py:251 msgid "This user already exists, but is a participant." msgstr "Cet⋅te utilisateur⋅rice existe déjà, mais en tant que participant⋅e." -#: participation/forms.py:264 +#: participation/forms.py:262 msgid "CSV file:" msgstr "Tableur au format CSV :" -#: participation/forms.py:288 +#: participation/forms.py:286 msgid "" "This file contains non-UTF-8 and non-ISO-8859-1 content. Please send your " "sheet as a CSV file." @@ -550,30 +549,30 @@ msgstr "" "Ce fichier contient des éléments non-UTF-8 et non-ISO-8859-1. Merci " "d'envoyer votre tableur au format CSV." -#: participation/forms.py:303 +#: participation/forms.py:301 msgid "Can't determine the pool size. Are you sure your file is correct?" msgstr "" "Impossible de déterminer la taille de la poule. Êtes-vous sûr⋅e que le " "fichier est correct ?" -#: participation/forms.py:323 +#: participation/forms.py:321 msgid "The following note is higher of the maximum expected value:" msgstr "La note suivante est supérieure au maximum attendu :" -#: participation/forms.py:329 +#: participation/forms.py:327 msgid "The following user was not found:" msgstr "L'utilisateur⋅rice suivant n'a pas été trouvé :" -#: participation/forms.py:343 +#: participation/forms.py:341 msgid "The defender, the opponent and the reporter must be different." msgstr "" "Les équipes défenseuse, opposante et rapportrice doivent être différent⋅es." -#: participation/forms.py:347 +#: participation/forms.py:345 msgid "This defender did not work on this problem." msgstr "Ce⋅tte défenseur⋅se ne travaille pas sur ce problème." -#: participation/forms.py:366 +#: participation/forms.py:364 msgid "The PDF file must not have more than 2 pages." msgstr "Le fichier PDF ne doit pas avoir plus de 2 pages." @@ -1326,7 +1325,7 @@ msgid "BigBlueButton link:" msgstr "Lien BigBlueButton :" #: participation/templates/participation/pool_detail.html:71 -#: participation/templates/participation/tournament_detail.html:105 +#: participation/templates/participation/tournament_detail.html:98 msgid "Ranking" msgstr "Classement" @@ -1550,7 +1549,7 @@ msgid "Invalidate" msgstr "Invalider" #: participation/templates/participation/team_detail.html:209 -#: participation/views.py:327 +#: participation/views.py:326 msgid "Upload motivation letter" msgstr "Envoyer la lettre de motivation" @@ -1559,7 +1558,7 @@ msgid "Update team" msgstr "Modifier l'équipe" #: participation/templates/participation/team_detail.html:219 -#: participation/views.py:436 +#: participation/views.py:463 msgid "Leave team" msgstr "Quitter l'équipe" @@ -1632,38 +1631,30 @@ msgstr "Pour contacter les équipes valides" msgid "Edit tournament" msgstr "Modifier le tournoi" -#: participation/templates/participation/tournament_detail.html:65 -msgid "Export as CSV" -msgstr "Exporter en CSV" - -#: participation/templates/participation/tournament_detail.html:72 +#: participation/templates/participation/tournament_detail.html:71 #: tfjm/templates/navbar.html:29 msgid "Teams" msgstr "Équipes" -#: participation/templates/participation/tournament_detail.html:80 +#: participation/templates/participation/tournament_detail.html:79 msgid "Access to payments list" msgstr "Accéder à la liste des paiements" -#: participation/templates/participation/tournament_detail.html:88 +#: participation/templates/participation/tournament_detail.html:87 msgid "Pools" msgstr "Poules" -#: participation/templates/participation/tournament_detail.html:96 -msgid "Add new pool" -msgstr "Ajouter une nouvelle poule" - -#: participation/templates/participation/tournament_detail.html:121 +#: participation/templates/participation/tournament_detail.html:114 msgid "Publish notes for first round" msgstr "Publier les notes pour le premier tour" -#: participation/templates/participation/tournament_detail.html:127 +#: participation/templates/participation/tournament_detail.html:120 msgid "Publish notes for second round" msgstr "Publier les notes pour le second tour" -#: participation/templates/participation/tournament_detail.html:138 -msgid "Add pool" -msgstr "Ajouter une poule" +#: participation/templates/participation/tournament_detail.html:133 +msgid "Files available for download" +msgstr "Fichiers disponibles au téléchargement" #: participation/templates/participation/tournament_list.html:6 #: tfjm/templates/base.html:67 @@ -1694,44 +1685,44 @@ msgstr "Modèles :" msgid "Warning: non-free format" msgstr "Attention : format non libre" -#: participation/views.py:56 tfjm/templates/base.html:79 +#: participation/views.py:55 tfjm/templates/base.html:79 #: tfjm/templates/navbar.html:35 msgid "Create team" msgstr "Créer une équipe" -#: participation/views.py:65 participation/views.py:106 +#: participation/views.py:64 participation/views.py:105 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." -#: participation/views.py:67 participation/views.py:108 +#: participation/views.py:66 participation/views.py:107 msgid "You are already in a team." msgstr "Vous êtes déjà dans une équipe." -#: participation/views.py:97 tfjm/templates/base.html:74 +#: participation/views.py:96 tfjm/templates/base.html:74 #: tfjm/templates/navbar.html:40 msgid "Join team" msgstr "Rejoindre une équipe" -#: participation/views.py:157 participation/views.py:474 +#: participation/views.py:156 participation/views.py:501 msgid "You don't participate, so you don't have any team." msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe." -#: participation/views.py:183 +#: participation/views.py:182 #, python-brace-format msgid "Detail of team {trigram}" msgstr "Détails de l'équipe {trigram}" -#: participation/views.py:212 +#: participation/views.py:211 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." -#: participation/views.py:215 +#: participation/views.py:214 msgid "The validation of the team is already done or pending." msgstr "La validation de l'équipe est déjà faite ou en cours." -#: participation/views.py:218 +#: participation/views.py:217 msgid "" "The team can't be validated: missing email address confirmations, " "authorizations, people, motivation letter or the tournament is not set." @@ -1740,123 +1731,128 @@ msgstr "" "d'adresse e-mail, soit une autorisation, soit des personnes, soit la lettre " "de motivation, soit le tournoi n'a pas été choisi." -#: participation/views.py:240 +#: participation/views.py:239 msgid "You are not an organizer of the tournament." msgstr "Vous n'êtes pas un⋅e organisateur⋅rice du tournoi." -#: participation/views.py:243 +#: participation/views.py:242 msgid "This team has no pending validation." msgstr "L'équipe n'a pas de validation en attente." -#: participation/views.py:270 +#: participation/views.py:269 msgid "You must specify if you validate the registration or not." msgstr "Vous devez spécifier si vous validez l'inscription ou non." -#: participation/views.py:305 +#: participation/views.py:304 #, python-brace-format msgid "Update team {trigram}" msgstr "Mise à jour de l'équipe {trigram}" -#: participation/views.py:366 participation/views.py:422 +#: participation/views.py:365 participation/views.py:448 #, python-brace-format msgid "Motivation letter of {team}.{ext}" msgstr "Lettre de motivation de {team}.{ext}" #: participation/views.py:397 #, python-brace-format +msgid "Authorizations of team {trigram}.zip" +msgstr "Autorisations de l'équipe {trigram}.zip" + +#: participation/views.py:401 +#, python-brace-format +msgid "Authorizations of {tournament}.zip" +msgstr "Autorisations du tournoi {tournament}.zip" + +#: participation/views.py:417 +#, python-brace-format msgid "Photo authorization of {participant}.{ext}" msgstr "Autorisation de droit à l'image de {participant}.{ext}" -#: participation/views.py:403 +#: participation/views.py:425 #, python-brace-format msgid "Parental authorization of {participant}.{ext}" msgstr "Autorisation parentale de {participant}.{ext}" -#: participation/views.py:410 +#: participation/views.py:433 #, python-brace-format msgid "Health sheet of {participant}.{ext}" msgstr "Fiche sanitaire de {participant}.{ext}" -#: participation/views.py:416 +#: participation/views.py:441 #, python-brace-format msgid "Vaccine sheet of {participant}.{ext}" msgstr "Carnet de vaccination de {participant}.{ext}" -#: participation/views.py:426 -#, python-brace-format -msgid "Photo authorizations of team {trigram}.zip" -msgstr "Autorisations de droit à l'image de l'équipe {trigram}.zip" - -#: participation/views.py:488 +#: participation/views.py:515 msgid "The team is not validated yet." msgstr "L'équipe n'est pas encore validée." -#: participation/views.py:502 +#: participation/views.py:529 #, python-brace-format msgid "Participation of team {trigram}" msgstr "Participation de l'équipe {trigram}" -#: participation/views.py:584 +#: participation/views.py:611 #, python-brace-format msgid "Payments of {tournament}" msgstr "Paiements de {tournament}" -#: participation/views.py:657 +#: participation/views.py:706 msgid "Notes published!" msgstr "Notes publiées !" -#: participation/views.py:693 +#: participation/views.py:742 msgid "You can't upload a solution after the deadline." msgstr "Vous ne pouvez pas envoyer de solution après la date limite." -#: participation/views.py:802 +#: participation/views.py:851 #, python-brace-format msgid "Solutions for pool {pool} of tournament {tournament}.zip" msgstr "Solutions pour la poule {pool} du tournoi {tournament}.zip" -#: participation/views.py:803 +#: participation/views.py:852 #, python-brace-format msgid "Syntheses for pool {pool} of tournament {tournament}.zip" msgstr "Notes de synthèses pour la poule {pool} du tournoi {tournament}.zip" -#: participation/views.py:833 +#: participation/views.py:881 #, python-brace-format msgid "Jury of pool {pool} for {tournament} with teams {teams}" msgstr "Jury de la poule {pool} pour {tournament} avec les équipes {teams}" -#: participation/views.py:849 +#: participation/views.py:897 #, python-brace-format msgid "The jury {name} is already in the pool!" msgstr "{name} est déjà dans la poule !" -#: participation/views.py:869 +#: participation/views.py:917 msgid "New TFJM² jury account" msgstr "Nouveau compte de juré⋅e pour le TFJM²" -#: participation/views.py:886 +#: participation/views.py:934 #, python-brace-format msgid "The jury {name} has been successfully added!" msgstr "{name} a été ajouté⋅e avec succès en tant que juré⋅e !" -#: participation/views.py:921 +#: participation/views.py:969 #, python-brace-format msgid "The jury {name} has been successfully removed!" msgstr "{name} a été retiré⋅e avec succès du jury !" -#: participation/views.py:947 +#: participation/views.py:995 #, python-brace-format msgid "The jury {name} has been successfully promoted president!" msgstr "{name} a été nommé⋅e président⋅e du jury !" -#: participation/views.py:975 +#: participation/views.py:1023 msgid "The following user is not registered as a jury:" msgstr "L'utilisateur⋅rice suivant n'est pas inscrit⋅e en tant que juré⋅e :" -#: participation/views.py:989 +#: participation/views.py:1037 msgid "Notes were successfully uploaded." msgstr "Les notes ont bien été envoyées." -#: participation/views.py:1694 +#: participation/views.py:1742 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." @@ -3326,3 +3322,12 @@ msgstr "Aucun résultat." #: tfjm/templates/sidebar.html:10 tfjm/templates/sidebar.html:21 msgid "Informations" msgstr "Informations" + +#~ msgid "Export as CSV" +#~ msgstr "Exporter en CSV" + +#~ msgid "Add new pool" +#~ msgstr "Ajouter une nouvelle poule" + +#~ msgid "Add pool" +#~ msgstr "Ajouter une poule" diff --git a/participation/templates/participation/team_detail.html b/participation/templates/participation/team_detail.html index 36524f5..93ee148 100644 --- a/participation/templates/participation/team_detail.html +++ b/participation/templates/participation/team_detail.html @@ -116,7 +116,7 @@ {% if user.registration.is_volunteer %} {% if user.registration in self.team.participation.tournament.organizers or user.registration.is_admin %} diff --git a/participation/templates/participation/tournament_detail.html b/participation/templates/participation/tournament_detail.html index e29f47c..901fc47 100644 --- a/participation/templates/participation/tournament_detail.html +++ b/participation/templates/participation/tournament_detail.html @@ -62,7 +62,6 @@ {% if user.registration.is_admin or user.registration in tournament.organizers.all %} {% endif %} @@ -91,12 +90,6 @@ {% endif %} - {% if user.registration.is_admin %} -
- -
- {% endif %} - {% if notes %}
@@ -134,20 +127,81 @@ {% endif %} - {% if user.registration.is_admin %} - {% trans "Add pool" as modal_title %} - {% trans "Add" as modal_button %} - {% url "participation:pool_create" as modal_action %} - {% include "base_modal.html" with modal_id="addPool" %} - {% endif %} -{% endblock %} + {% if user.registration.is_admin or user.registration in tournament.organizers.all %} +
+ +

{% trans "Files available for download" %}

+ +
+

IMPORTANT

+ +

+ Les fichiers accessibles ci-dessous peuvent contenir des informations personnelles. + Par conformité avec le droit européen et par respect de la confidentialité des données + des participant⋅es, vous ne devez utiliser ces données que dans un cadre strictement + nécessaire en lien avec l'organisation du tournoi. +

+ +

+ De plus, il est de votre responsabilité de supprimer ces fichiers une fois que vous + n'en avez plus besoin, notamment à la fin du tournoi. +

+ +

+ +

+
+ + + {% endif %} -{% block extrajavascript %} - {% endblock %} diff --git a/participation/urls.py b/participation/urls.py index 8a37dbb..d4d064a 100644 --- a/participation/urls.py +++ b/participation/urls.py @@ -25,7 +25,7 @@ urlpatterns = [ path("team//update/", TeamUpdateView.as_view(), name="update_team"), path("team//upload-motivation-letter/", TeamUploadMotivationLetterView.as_view(), name="upload_team_motivation_letter"), - path("team//authorizations/", TeamAuthorizationsView.as_view(), name="team_authorizations"), + path("team//authorizations/", TeamAuthorizationsView.as_view(), name="team_authorizations"), path("team/leave/", TeamLeaveView.as_view(), name="team_leave"), path("detail/", MyParticipationDetailView.as_view(), name="my_participation_detail"), path("detail//", ParticipationDetailView.as_view(), name="participation_detail"), @@ -36,6 +36,8 @@ urlpatterns = [ path("tournament//update/", TournamentUpdateView.as_view(), name="tournament_update"), path("tournament//payments/", TournamentPaymentsView.as_view(), name="tournament_payments"), path("tournament//csv/", TournamentExportCSVView.as_view(), name="tournament_csv"), + path("tournament//authorizations/", TeamAuthorizationsView.as_view(), + name="tournament_authorizations"), path("tournament//publish-notes//", TournamentPublishNotesView.as_view(), name="tournament_publish_notes"), path("pools/create/", PoolCreateView.as_view(), name="pool_create"), diff --git a/participation/views.py b/participation/views.py index 287c9c0..e7320ab 100644 --- a/participation/views.py +++ b/participation/views.py @@ -366,63 +366,91 @@ class MotivationLetterView(LoginRequiredMixin, View): return FileResponse(open(path, "rb"), content_type=mime_type, filename=true_file_name) -class TeamAuthorizationsView(LoginRequiredMixin, DetailView): +class TeamAuthorizationsView(LoginRequiredMixin, View): """ Get as a ZIP archive all the authorizations that are sent """ - model = Team def dispatch(self, request, *args, **kwargs): user = request.user if not user.is_authenticated: return super().handle_no_permission() + + if 'team_id' in kwargs: + team = Team.objects.get(pk=kwargs["team_id"]) + tournament = team.participation.tournament + else: + team = None + tournament = Tournament.objects.get(pk=kwargs["tournament_id"]) + if user.registration.is_admin or user.registration.is_volunteer \ - and (user.registration in self.get_object().participation.tournament.organizers - or self.get_object().participation.final - and user.registration in Tournament.final_tournament().organizers): + and (user.registration in tournament.organizers + or (team is not None and team.participation.final + and user.registration in Tournament.final_tournament().organizers)): return super().dispatch(request, *args, **kwargs) raise PermissionDenied def get(self, request, *args, **kwargs): - team = self.get_object() + if 'team_id' in kwargs: + team = Team.objects.get(pk=kwargs["team_id"]) + teams = [team] + filename = _("Authorizations of team {trigram}.zip").format(trigram=team.trigram) + else: + tournament = Tournament.objects.get(pk=kwargs["tournament_id"]) + teams = [p.team for p in tournament.participations.filter(valid=True)] + filename = _("Authorizations of {tournament}.zip").format(tournament=tournament.name) + magic = Magic(mime=True) output = BytesIO() zf = ZipFile(output, "w") - for participant in team.participants.all(): - if participant.photo_authorization: - mime_type = magic.from_file("media/" + participant.photo_authorization.name) - ext = mime_type.split("/")[1].replace("jpeg", "jpg") - zf.write("media/" + participant.photo_authorization.name, - _("Photo authorization of {participant}.{ext}").format(participant=str(participant), ext=ext)) + for team in teams: + team_prefix = f"{team.trigram}/" if len(teams) > 1 else "" - if isinstance(participant, StudentRegistration) and participant.parental_authorization: - mime_type = magic.from_file("media/" + participant.parental_authorization.name) - ext = mime_type.split("/")[1].replace("jpeg", "jpg") - zf.write("media/" + participant.parental_authorization.name, - _("Parental authorization of {participant}.{ext}") - .format(participant=str(participant), ext=ext)) + for participant in team.participants.all(): + user_prefix = f"{team_prefix}{participant.user.first_name} {participant.user.last_name}/" - if isinstance(participant, StudentRegistration) and participant.health_sheet: - mime_type = magic.from_file("media/" + participant.health_sheet.name) - ext = mime_type.split("/")[1].replace("jpeg", "jpg") - zf.write("media/" + participant.health_sheet.name, - _("Health sheet of {participant}.{ext}").format(participant=str(participant), ext=ext)) + if participant.photo_authorization \ + and participant.photo_authorization.storage.exists(participant.photo_authorization.path): + mime_type = magic.from_file("media/" + participant.photo_authorization.name) + ext = mime_type.split("/")[1].replace("jpeg", "jpg") + zf.write("media/" + participant.photo_authorization.name, + user_prefix + _("Photo authorization of {participant}.{ext}") + .format(participant=str(participant), ext=ext)) - if isinstance(participant, StudentRegistration) and participant.vaccine_sheet: - mime_type = magic.from_file("media/" + participant.vaccine_sheet.name) - ext = mime_type.split("/")[1].replace("jpeg", "jpg") - zf.write("media/" + participant.vaccine_sheet.name, - _("Vaccine sheet of {participant}.{ext}").format(participant=str(participant), ext=ext)) + if participant.is_student and participant.parental_authorization \ + and participant.parental_authorization.storage.exists(participant.parental_authorization.path): + mime_type = magic.from_file("media/" + participant.parental_authorization.name) + ext = mime_type.split("/")[1].replace("jpeg", "jpg") + zf.write("media/" + participant.parental_authorization.name, + user_prefix + _("Parental authorization of {participant}.{ext}") + .format(participant=str(participant), ext=ext)) + + if participant.is_student and participant.health_sheet \ + and participant.health_sheet.storage.exists(participant.health_sheet.path): + mime_type = magic.from_file("media/" + participant.health_sheet.name) + ext = mime_type.split("/")[1].replace("jpeg", "jpg") + zf.write("media/" + participant.health_sheet.name, + user_prefix + _("Health sheet of {participant}.{ext}") + .format(participant=str(participant), ext=ext)) + + if participant.is_student and participant.vaccine_sheet \ + and participant.vaccine_sheet.storage.exists(participant.vaccine_sheet.path): + mime_type = magic.from_file("media/" + participant.vaccine_sheet.name) + ext = mime_type.split("/")[1].replace("jpeg", "jpg") + zf.write("media/" + participant.vaccine_sheet.name, + user_prefix + _("Vaccine sheet of {participant}.{ext}") + .format(participant=str(participant), ext=ext)) + + if team.motivation_letter and team.motivation_letter.storage.exists(team.motivation_letter.path): + mime_type = magic.from_file("media/" + team.motivation_letter.name) + ext = mime_type.split("/")[1].replace("jpeg", "jpg") + zf.write("media/" + team.motivation_letter.name, + team_prefix + _("Motivation letter of {team}.{ext}") + .format(team=str(team), ext=ext)) - if team.motivation_letter: - mime_type = magic.from_file("media/" + team.motivation_letter.name) - ext = mime_type.split("/")[1].replace("jpeg", "jpg") - zf.write("media/" + team.motivation_letter.name, - _("Motivation letter of {team}.{ext}").format(team=str(team), ext=ext)) zf.close() response = HttpResponse(content_type="application/zip") - response["Content-Disposition"] = "attachment; filename=\"{filename}\"" \ - .format(filename=_("Photo authorizations of team {trigram}.zip").format(trigram=team.trigram)) + response["Content-Disposition"] = f"attachment; filename=\"{filename}\"" response.write(output.getvalue()) return response