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"),
)
valid = models.BooleanField(
null=True,
default=None,
verbose_name=_("valid"),
help_text=_("The video got the validation of the administrators."),
)
solution = models.OneToOneField(
"participation.Video",
on_delete=models.SET_NULL,

View File

@ -61,13 +61,17 @@
</div>
</div>
<hr>
{% if team.participation.valid %}
<hr>
<div class="text-center">
<a class="btn btn-info" href="{% url "participation:participation_detail" pk=team.participation.pk %}">
<i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i>
</a>
</div>
<div class="text-center">
<a class="btn btn-info" href="{% url "participation:participation_detail" pk=team.participation.pk %}">
<i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i>
</a>
</div>
{% else %}
{# TODO Validate team #}
{% endif %}
{% trans "Update team" as modal_title %}
{% trans "Update" as modal_button %}

View File

@ -170,6 +170,8 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
def dispatch(self, request, *args, **kwargs):
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\
and user.registration.team.participation.pk == kwargs["pk"]:
return super().dispatch(request, *args, **kwargs)

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Corres2math\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"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -99,7 +99,7 @@ msgstr "changelogs"
msgid "Changelog of type \"{action}\" for model {model} at {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."
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."
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"
msgstr "nom"
#: apps/participation/models.py:21
#: apps/participation/models.py:22
msgid "trigram"
msgstr "trigramme"
#: apps/participation/models.py:29
#: apps/participation/models.py:30
msgid "access code"
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."
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"
msgstr "Autoriser Animath à publier ma vidéo"
#: apps/participation/models.py:35
#: apps/participation/models.py:36
msgid ""
"Give the authorisation to publish the video on the main website to promote "
"the action."
@ -135,80 +135,80 @@ msgstr ""
"Donner l'autorisation de publier la vidéo sur le site principal pour "
"promouvoir les Correspondances."
#: apps/participation/models.py:45
#: apps/participation/models.py:59
#, python-brace-format
msgid "Team {name} ({trigram})"
msgstr "Équipe {name} ({trigram})"
#: apps/participation/models.py:48 apps/participation/models.py:59
#: apps/registration/models.py:85 apps/registration/models.py:131
#: apps/participation/models.py:62 apps/participation/models.py:73
#: apps/registration/models.py:85 apps/registration/models.py:130
msgid "team"
msgstr "équipe"
#: apps/participation/models.py:49
#: apps/participation/models.py:63
msgid "teams"
msgstr "équipes"
#: apps/participation/models.py:63
#: apps/participation/models.py:77
#, python-brace-format
msgid "Problem #{problem:d}"
msgstr "Problème n°{problem:d}"
#: apps/participation/models.py:66
#: apps/participation/models.py:80
msgid "problem number"
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"
msgstr "vidéo de solution"
#: apps/participation/models.py:84
#: apps/participation/models.py:105
msgid "received participation"
msgstr "participation reçue"
#: apps/participation/models.py:93
#: apps/participation/models.py:114
msgid "synthesis video"
msgstr "vidéo de synthèse"
#: apps/participation/models.py:97
#: apps/participation/models.py:118
#, python-brace-format
msgid "Participation of the team {name} ({trigram})"
msgstr "Participation de l'équipe {name} ({trigram})"
#: apps/participation/models.py:100
#: apps/participation/models.py:121
msgid "participation"
msgstr "participation"
#: apps/participation/models.py:101
#: apps/participation/models.py:122
msgid "participations"
msgstr "participations"
#: apps/participation/models.py:106
#: apps/participation/models.py:127
msgid "link"
msgstr "lien"
#: apps/participation/models.py:107
#: apps/participation/models.py:128
msgid "The full video link."
msgstr "Le lien complet de la vidéo."
#: apps/participation/models.py:113
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
#: apps/participation/models.py:157
#, python-brace-format
msgid "Video of team {name} ({trigram})"
msgstr "Vidéo de l'équipe {name} ({trigram})"
#: apps/participation/models.py:140
#: apps/participation/models.py:161
msgid "video"
msgstr "vidéo"
#: apps/participation/models.py:141
#: apps/participation/models.py:162
msgid "videos"
msgstr "vidéos"
@ -223,7 +223,9 @@ msgid "Join"
msgstr "Rejoindre"
#: 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:26
msgid "any"
@ -239,7 +241,7 @@ msgid "Team:"
msgstr "Équipe :"
#: 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:"
msgstr "Problème choisi :"
@ -267,40 +269,40 @@ msgstr "La plateforme de cette vidéo n'est pas encore supportée."
msgid "Upload video"
msgstr "Envoyer la vidéo"
#: apps/participation/templates/participation/team_detail.html:14
#: apps/participation/templates/participation/team_detail.html:13
msgid "Name:"
msgstr "Nom :"
#: apps/participation/templates/participation/team_detail.html:17
#: apps/participation/templates/participation/team_detail.html:16
msgid "Trigram:"
msgstr "Trigramme :"
#: apps/participation/templates/participation/team_detail.html:20
#: apps/participation/templates/participation/team_detail.html:19
msgid "Access code:"
msgstr "Code d'accès :"
#: apps/participation/templates/participation/team_detail.html:23
#: apps/participation/templates/participation/team_detail.html:22
msgid "Coachs:"
msgstr "Encadrants :"
#: apps/participation/templates/participation/team_detail.html:26
#: apps/participation/templates/participation/team_detail.html:31
msgid "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:"
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:"
msgstr "Autorisations :"
#: apps/participation/templates/participation/team_detail.html:41
#: apps/participation/templates/participation/team_detail.html:53
msgid "Not uploaded yet"
msgstr "Pas encore envoyée"
#: apps/participation/templates/participation/team_detail.html:48
#: apps/participation/templates/participation/team_detail.html:61
#: apps/participation/templates/participation/team_detail.html:60
#: apps/participation/templates/participation/team_detail.html:73
#: apps/participation/templates/participation/update_team.html:12
#: apps/registration/templates/registration/update_user.html:12
#: apps/registration/templates/registration/user_detail.html:64
@ -308,40 +310,55 @@ msgstr "Pas encore envoyée"
msgid "Update"
msgstr "Modifier"
#: apps/participation/templates/participation/team_detail.html:56
#: apps/participation/templates/participation/team_detail.html:68
msgid "Access to team participation"
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"
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
msgid "Create team"
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."
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."
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
msgid "Join team"
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."
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."
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
msgid "role"
msgstr "rôle"
@ -350,7 +367,7 @@ msgstr "rôle"
msgid "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"
msgstr "encadrant"
@ -399,47 +416,47 @@ msgstr "classe"
msgid "school"
msgstr "école"
#: apps/registration/models.py:104
#: apps/registration/models.py:103
msgid "photo authorization"
msgstr "autorisation de droit à l'image"
#: apps/registration/models.py:112
#: apps/registration/models.py:111
msgid "student"
msgstr "étudiant"
#: apps/registration/models.py:120
#: apps/registration/models.py:119
msgid "student registration"
msgstr "inscription d'élève"
#: apps/registration/models.py:121
#: apps/registration/models.py:120
msgid "student registrations"
msgstr "inscriptions d'élève"
#: apps/registration/models.py:135
#: apps/registration/models.py:134
msgid "professional activity"
msgstr "activité professionnelle"
#: apps/registration/models.py:148
#: apps/registration/models.py:147
msgid "coach registration"
msgstr "inscription d'encadrant"
#: apps/registration/models.py:149
#: apps/registration/models.py:148
msgid "coach registrations"
msgstr "inscriptions d'encadrants"
#: apps/registration/models.py:154
#: apps/registration/models.py:153
msgid "role of the administrator"
msgstr "rôle de l'administrateur"
#: apps/registration/models.py:159
#: apps/registration/models.py:158
msgid "admin"
msgstr "admin"
#: apps/registration/models.py:167
#: apps/registration/models.py:166
msgid "admin registration"
msgstr "inscription d'administrateur"
#: apps/registration/models.py:168
#: apps/registration/models.py:167
msgid "admin registrations"
msgstr "inscriptions d'administrateur"
@ -690,11 +707,6 @@ msgstr "Mail de confirmation de l'adresse mail envoyé"
msgid "Resend email validation link"
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
msgid "English"
msgstr "Anglais"