Don't access to team participation if the team is not validated

This commit is contained in:
Yohann D'ANELLO 2020-10-11 16:00:43 +02:00
parent 6e8b6fbc66
commit 552ea17f7d
4 changed files with 101 additions and 76 deletions

View File

@ -80,6 +80,13 @@ class Participation(models.Model):
verbose_name=_("problem number"), verbose_name=_("problem number"),
) )
valid = models.BooleanField(
null=True,
default=None,
verbose_name=_("valid"),
help_text=_("The video got the validation of the administrators."),
)
solution = models.OneToOneField( solution = models.OneToOneField(
"participation.Video", "participation.Video",
on_delete=models.SET_NULL, on_delete=models.SET_NULL,

View File

@ -61,6 +61,7 @@
</div> </div>
</div> </div>
{% if team.participation.valid %}
<hr> <hr>
<div class="text-center"> <div class="text-center">
@ -68,6 +69,9 @@
<i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i> <i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i>
</a> </a>
</div> </div>
{% else %}
{# TODO Validate team #}
{% endif %}
{% trans "Update team" as modal_title %} {% trans "Update team" as modal_title %}
{% trans "Update" as modal_button %} {% trans "Update" as modal_button %}

View File

@ -170,6 +170,8 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
user = request.user user = request.user
if not self.get_object().valid:
raise PermissionDenied(_("The team is not validated yet."))
if user.registration.is_admin or user.registration.participates\ if user.registration.is_admin or user.registration.participates\
and user.registration.team.participation.pk == kwargs["pk"]: and user.registration.team.participation.pk == kwargs["pk"]:
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Corres2math\n" "Project-Id-Version: Corres2math\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-27 18:00+0200\n" "POT-Creation-Date: 2020-10-11 15:58+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n" "Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -99,7 +99,7 @@ msgstr "changelogs"
msgid "Changelog of type \"{action}\" for model {model} at {timestamp}" msgid "Changelog of type \"{action}\" for model {model} at {timestamp}"
msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}" msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
#: apps/participation/forms.py:14 apps/participation/models.py:22 #: apps/participation/forms.py:14 apps/participation/models.py:23
msgid "The trigram must be composed of three uppercase letters." msgid "The trigram must be composed of three uppercase letters."
msgstr "Le trigramme doit être composé de trois lettres majuscules." msgstr "Le trigramme doit être composé de trois lettres majuscules."
@ -107,27 +107,27 @@ msgstr "Le trigramme doit être composé de trois lettres majuscules."
msgid "No team was found with this access code." msgid "No team was found with this access code."
msgstr "Aucune équipe n'a été trouvée avec ce code d'accès." msgstr "Aucune équipe n'a été trouvée avec ce code d'accès."
#: apps/participation/models.py:15 #: apps/participation/models.py:16
msgid "name" msgid "name"
msgstr "nom" msgstr "nom"
#: apps/participation/models.py:21 #: apps/participation/models.py:22
msgid "trigram" msgid "trigram"
msgstr "trigramme" msgstr "trigramme"
#: apps/participation/models.py:29 #: apps/participation/models.py:30
msgid "access code" msgid "access code"
msgstr "code d'accès" msgstr "code d'accès"
#: apps/participation/models.py:30 #: apps/participation/models.py:31
msgid "The access code let other people to join the team." msgid "The access code let other people to join the team."
msgstr "Le code d'accès permet aux autres participants de rejoindre l'équipe." msgstr "Le code d'accès permet aux autres participants de rejoindre l'équipe."
#: apps/participation/models.py:34 #: apps/participation/models.py:35
msgid "Grant Animath to publish my video" msgid "Grant Animath to publish my video"
msgstr "Autoriser Animath à publier ma vidéo" msgstr "Autoriser Animath à publier ma vidéo"
#: apps/participation/models.py:35 #: apps/participation/models.py:36
msgid "" msgid ""
"Give the authorisation to publish the video on the main website to promote " "Give the authorisation to publish the video on the main website to promote "
"the action." "the action."
@ -135,80 +135,80 @@ msgstr ""
"Donner l'autorisation de publier la vidéo sur le site principal pour " "Donner l'autorisation de publier la vidéo sur le site principal pour "
"promouvoir les Correspondances." "promouvoir les Correspondances."
#: apps/participation/models.py:45 #: apps/participation/models.py:59
#, python-brace-format #, python-brace-format
msgid "Team {name} ({trigram})" msgid "Team {name} ({trigram})"
msgstr "Équipe {name} ({trigram})" msgstr "Équipe {name} ({trigram})"
#: apps/participation/models.py:48 apps/participation/models.py:59 #: apps/participation/models.py:62 apps/participation/models.py:73
#: apps/registration/models.py:85 apps/registration/models.py:131 #: apps/registration/models.py:85 apps/registration/models.py:130
msgid "team" msgid "team"
msgstr "équipe" msgstr "équipe"
#: apps/participation/models.py:49 #: apps/participation/models.py:63
msgid "teams" msgid "teams"
msgstr "équipes" msgstr "équipes"
#: apps/participation/models.py:63 #: apps/participation/models.py:77
#, python-brace-format #, python-brace-format
msgid "Problem #{problem:d}" msgid "Problem #{problem:d}"
msgstr "Problème n°{problem:d}" msgstr "Problème n°{problem:d}"
#: apps/participation/models.py:66 #: apps/participation/models.py:80
msgid "problem number" msgid "problem number"
msgstr "numéro de problème" msgstr "numéro de problème"
#: apps/participation/models.py:75 #: apps/participation/models.py:86 apps/participation/models.py:134
msgid "valid"
msgstr "valide"
#: apps/participation/models.py:87 apps/participation/models.py:135
msgid "The video got the validation of the administrators."
msgstr "La vidéo a été validée par les administrateurs."
#: apps/participation/models.py:96
msgid "solution video" msgid "solution video"
msgstr "vidéo de solution" msgstr "vidéo de solution"
#: apps/participation/models.py:84 #: apps/participation/models.py:105
msgid "received participation" msgid "received participation"
msgstr "participation reçue" msgstr "participation reçue"
#: apps/participation/models.py:93 #: apps/participation/models.py:114
msgid "synthesis video" msgid "synthesis video"
msgstr "vidéo de synthèse" msgstr "vidéo de synthèse"
#: apps/participation/models.py:97 #: apps/participation/models.py:118
#, python-brace-format #, python-brace-format
msgid "Participation of the team {name} ({trigram})" msgid "Participation of the team {name} ({trigram})"
msgstr "Participation de l'équipe {name} ({trigram})" msgstr "Participation de l'équipe {name} ({trigram})"
#: apps/participation/models.py:100 #: apps/participation/models.py:121
msgid "participation" msgid "participation"
msgstr "participation" msgstr "participation"
#: apps/participation/models.py:101 #: apps/participation/models.py:122
msgid "participations" msgid "participations"
msgstr "participations" msgstr "participations"
#: apps/participation/models.py:106 #: apps/participation/models.py:127
msgid "link" msgid "link"
msgstr "lien" msgstr "lien"
#: apps/participation/models.py:107 #: apps/participation/models.py:128
msgid "The full video link." msgid "The full video link."
msgstr "Le lien complet de la vidéo." msgstr "Le lien complet de la vidéo."
#: apps/participation/models.py:113 #: apps/participation/models.py:157
msgid "valid"
msgstr "valide"
#: apps/participation/models.py:114
msgid "The video got the validation of the administrators."
msgstr "La vidéo a été validée par les administrateurs."
#: apps/participation/models.py:136
#, python-brace-format #, python-brace-format
msgid "Video of team {name} ({trigram})" msgid "Video of team {name} ({trigram})"
msgstr "Vidéo de l'équipe {name} ({trigram})" msgstr "Vidéo de l'équipe {name} ({trigram})"
#: apps/participation/models.py:140 #: apps/participation/models.py:161
msgid "video" msgid "video"
msgstr "vidéo" msgstr "vidéo"
#: apps/participation/models.py:141 #: apps/participation/models.py:162
msgid "videos" msgid "videos"
msgstr "vidéos" msgstr "vidéos"
@ -223,7 +223,9 @@ msgid "Join"
msgstr "Rejoindre" msgstr "Rejoindre"
#: apps/participation/templates/participation/participation_detail.html:6 #: apps/participation/templates/participation/participation_detail.html:6
#: apps/participation/templates/participation/team_detail.html:6 #: apps/participation/templates/participation/team_detail.html:27
#: apps/participation/templates/participation/team_detail.html:36
#: apps/participation/templates/participation/team_detail.html:41
#: apps/registration/templates/registration/user_detail.html:6 #: apps/registration/templates/registration/user_detail.html:6
#: apps/registration/templates/registration/user_detail.html:26 #: apps/registration/templates/registration/user_detail.html:26
msgid "any" msgid "any"
@ -239,7 +241,7 @@ msgid "Team:"
msgstr "Équipe :" msgstr "Équipe :"
#: apps/participation/templates/participation/participation_detail.html:16 #: apps/participation/templates/participation/participation_detail.html:16
#: apps/participation/templates/participation/team_detail.html:29 #: apps/participation/templates/participation/team_detail.html:40
msgid "Chosen problem:" msgid "Chosen problem:"
msgstr "Problème choisi :" msgstr "Problème choisi :"
@ -267,40 +269,40 @@ msgstr "La plateforme de cette vidéo n'est pas encore supportée."
msgid "Upload video" msgid "Upload video"
msgstr "Envoyer la vidéo" msgstr "Envoyer la vidéo"
#: apps/participation/templates/participation/team_detail.html:14 #: apps/participation/templates/participation/team_detail.html:13
msgid "Name:" msgid "Name:"
msgstr "Nom :" msgstr "Nom :"
#: apps/participation/templates/participation/team_detail.html:17 #: apps/participation/templates/participation/team_detail.html:16
msgid "Trigram:" msgid "Trigram:"
msgstr "Trigramme :" msgstr "Trigramme :"
#: apps/participation/templates/participation/team_detail.html:20 #: apps/participation/templates/participation/team_detail.html:19
msgid "Access code:" msgid "Access code:"
msgstr "Code d'accès :" msgstr "Code d'accès :"
#: apps/participation/templates/participation/team_detail.html:23 #: apps/participation/templates/participation/team_detail.html:22
msgid "Coachs:" msgid "Coachs:"
msgstr "Encadrants :" msgstr "Encadrants :"
#: apps/participation/templates/participation/team_detail.html:26 #: apps/participation/templates/participation/team_detail.html:31
msgid "Participants:" msgid "Participants:"
msgstr "Participants :" msgstr "Participants :"
#: apps/participation/templates/participation/team_detail.html:32 #: apps/participation/templates/participation/team_detail.html:44
msgid "Grant Animath to publish our video:" msgid "Grant Animath to publish our video:"
msgstr "Autoriser Animath à publier notre vidéo :" msgstr "Autoriser Animath à publier notre vidéo :"
#: apps/participation/templates/participation/team_detail.html:35 #: apps/participation/templates/participation/team_detail.html:47
msgid "Authorizations:" msgid "Authorizations:"
msgstr "Autorisations :" msgstr "Autorisations :"
#: apps/participation/templates/participation/team_detail.html:41 #: apps/participation/templates/participation/team_detail.html:53
msgid "Not uploaded yet" msgid "Not uploaded yet"
msgstr "Pas encore envoyée" msgstr "Pas encore envoyée"
#: apps/participation/templates/participation/team_detail.html:48 #: apps/participation/templates/participation/team_detail.html:60
#: apps/participation/templates/participation/team_detail.html:61 #: apps/participation/templates/participation/team_detail.html:73
#: apps/participation/templates/participation/update_team.html:12 #: apps/participation/templates/participation/update_team.html:12
#: apps/registration/templates/registration/update_user.html:12 #: apps/registration/templates/registration/update_user.html:12
#: apps/registration/templates/registration/user_detail.html:64 #: apps/registration/templates/registration/user_detail.html:64
@ -308,40 +310,55 @@ msgstr "Pas encore envoyée"
msgid "Update" msgid "Update"
msgstr "Modifier" msgstr "Modifier"
#: apps/participation/templates/participation/team_detail.html:56 #: apps/participation/templates/participation/team_detail.html:68
msgid "Access to team participation" msgid "Access to team participation"
msgstr "Accéder à la participation de l'équipe" msgstr "Accéder à la participation de l'équipe"
#: apps/participation/templates/participation/team_detail.html:60 #: apps/participation/templates/participation/team_detail.html:72
msgid "Update team" msgid "Update team"
msgstr "Modifier l'équipe" msgstr "Modifier l'équipe"
#: apps/participation/views.py:15 templates/base.html:70 #: apps/participation/views.py:21 templates/base.html:70
#: templates/base.html:206 #: templates/base.html:206
msgid "Create team" msgid "Create team"
msgstr "Créer une équipe" msgstr "Créer une équipe"
#: apps/participation/views.py:22 apps/participation/views.py:50 #: apps/participation/views.py:28 apps/participation/views.py:58
msgid "You don't participate, so you can't create a team." 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." msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe."
#: apps/participation/views.py:24 apps/participation/views.py:52 #: apps/participation/views.py:30 apps/participation/views.py:60
msgid "You are already in a team." msgid "You are already in a team."
msgstr "Vous êtes déjà dans une équipe." msgstr "Vous êtes déjà dans une équipe."
#: apps/participation/views.py:43 templates/base.html:75 #: apps/participation/views.py:51 templates/base.html:75
#: templates/base.html:202 #: templates/base.html:202
msgid "Join team" msgid "Join team"
msgstr "Rejoindre une équipe" msgstr "Rejoindre une équipe"
#: apps/participation/views.py:76 apps/participation/views.py:127 #: apps/participation/views.py:86 apps/participation/views.py:164
msgid "You are not in a team." msgid "You are not in a team."
msgstr "Vous n'êtes pas dans une équipe." msgstr "Vous n'êtes pas dans une équipe."
#: apps/participation/views.py:77 apps/participation/views.py:128 #: apps/participation/views.py:87 apps/participation/views.py:165
msgid "You don't participate, so you don't have any team." msgid "You don't participate, so you don't have any team."
msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe." msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe."
#: apps/participation/views.py:148 apps/registration/views.py:213
#, python-brace-format
msgid "Photo authorization of {student}.{ext}"
msgstr "Autorisation de droit à l'image de {student}.{ext}"
#: apps/participation/views.py:152
#, fuzzy, python-brace-format
#| msgid "Photo authorization of {student}.{ext}"
msgid "Photo authorizations of team {trigram}.zip"
msgstr "Autorisation de droit à l'image de {student}.{ext}"
#: apps/participation/views.py:174
msgid "The team is not validated yet."
msgstr "L'équipe n'est pas encore validée."
#: apps/registration/forms.py:13 #: apps/registration/forms.py:13
msgid "role" msgid "role"
msgstr "rôle" msgstr "rôle"
@ -350,7 +367,7 @@ msgstr "rôle"
msgid "participant" msgid "participant"
msgstr "participant" msgstr "participant"
#: apps/registration/forms.py:16 apps/registration/models.py:140 #: apps/registration/forms.py:16 apps/registration/models.py:139
msgid "coach" msgid "coach"
msgstr "encadrant" msgstr "encadrant"
@ -399,47 +416,47 @@ msgstr "classe"
msgid "school" msgid "school"
msgstr "école" msgstr "école"
#: apps/registration/models.py:104 #: apps/registration/models.py:103
msgid "photo authorization" msgid "photo authorization"
msgstr "autorisation de droit à l'image" msgstr "autorisation de droit à l'image"
#: apps/registration/models.py:112 #: apps/registration/models.py:111
msgid "student" msgid "student"
msgstr "étudiant" msgstr "étudiant"
#: apps/registration/models.py:120 #: apps/registration/models.py:119
msgid "student registration" msgid "student registration"
msgstr "inscription d'élève" msgstr "inscription d'élève"
#: apps/registration/models.py:121 #: apps/registration/models.py:120
msgid "student registrations" msgid "student registrations"
msgstr "inscriptions d'élève" msgstr "inscriptions d'élève"
#: apps/registration/models.py:135 #: apps/registration/models.py:134
msgid "professional activity" msgid "professional activity"
msgstr "activité professionnelle" msgstr "activité professionnelle"
#: apps/registration/models.py:148 #: apps/registration/models.py:147
msgid "coach registration" msgid "coach registration"
msgstr "inscription d'encadrant" msgstr "inscription d'encadrant"
#: apps/registration/models.py:149 #: apps/registration/models.py:148
msgid "coach registrations" msgid "coach registrations"
msgstr "inscriptions d'encadrants" msgstr "inscriptions d'encadrants"
#: apps/registration/models.py:154 #: apps/registration/models.py:153
msgid "role of the administrator" msgid "role of the administrator"
msgstr "rôle de l'administrateur" msgstr "rôle de l'administrateur"
#: apps/registration/models.py:159 #: apps/registration/models.py:158
msgid "admin" msgid "admin"
msgstr "admin" msgstr "admin"
#: apps/registration/models.py:167 #: apps/registration/models.py:166
msgid "admin registration" msgid "admin registration"
msgstr "inscription d'administrateur" msgstr "inscription d'administrateur"
#: apps/registration/models.py:168 #: apps/registration/models.py:167
msgid "admin registrations" msgid "admin registrations"
msgstr "inscriptions d'administrateur" msgstr "inscriptions d'administrateur"
@ -690,11 +707,6 @@ msgstr "Mail de confirmation de l'adresse mail envoyé"
msgid "Resend email validation link" msgid "Resend email validation link"
msgstr "Renvoyé le lien de validation de l'adresse mail" msgstr "Renvoyé le lien de validation de l'adresse mail"
#: apps/registration/views.py:213
#, python-brace-format
msgid "Photo authorization of {student}.{ext}"
msgstr "Autorisation de droit à l'image de {student}.{ext}"
#: corres2math/settings.py:150 #: corres2math/settings.py:150
msgid "English" msgid "English"
msgstr "Anglais" msgstr "Anglais"