Teams can request a validation

This commit is contained in:
Yohann D'ANELLO 2020-10-11 16:30:02 +02:00
parent 552ea17f7d
commit 427786769f
4 changed files with 116 additions and 34 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 3.1.1 on 2020-10-11 13:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('participation', '0004_auto_20200927_1322'),
]
operations = [
migrations.AddField(
model_name='participation',
name='valid',
field=models.BooleanField(default=None, help_text='The video got the validation of the administrators.', null=True, verbose_name='valid'),
),
]

View File

@ -1,6 +1,7 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load i18n %} {% load i18n %}
{% load crispy_forms_filters %}
{% block content %} {% block content %}
@ -61,16 +62,42 @@
</div> </div>
</div> </div>
{% if team.participation.valid %} <hr>
<hr>
{% if team.participation.valid %}
<div class="text-center"> <div class="text-center">
<a class="btn btn-info" href="{% url "participation:participation_detail" pk=team.participation.pk %}"> <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> <i class="fas fa-video"></i> {% trans "Access to team participation" %} <i class="fas fa-video"></i>
</a> </a>
</div> </div>
{% else %} {% elif team.participation.valid is None %} {# Team did not ask for validation #}
{# TODO Validate team #} {% if user.registration.participates %}
{% if can_validate %}
<div class="alert alert-info">
{% trans "Your team has at least 3 members and all photo authorizations were given: the team can be validated." %}
<div class="text-center">
<button class="btn btn-success">{% trans "Submit my team to validation" %}</button>
</div>
</div>
{% else %}
<div class="alert alert-warning">
{% trans "Your team must be composed of 3 members and each member must upload its photo authorization." %}
</div>
{% endif %}
{% else %}
<div class="alert alert-warning">
{% trans "This team didn't ask for validation yet." %}
</div>
{% endif %}
{% else %} {# Team is waiting for validation #}
{% if user.registration.participates %}
<div class="alert alert-warning">
{% trans "Your validation is pending." %}
</div>
{% else %}
Team asked for validation.
{# TODO Add validation form: validate or invalidate, with a message #}
{% endif %}
{% endif %} {% endif %}
{% trans "Update team" as modal_title %} {% trans "Update team" as modal_title %}

View File

@ -90,12 +90,22 @@ class MyTeamDetailView(LoginRequiredMixin, RedirectView):
class TeamDetailView(LoginRequiredMixin, DetailView): class TeamDetailView(LoginRequiredMixin, DetailView):
model = Team model = Team
def dispatch(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
user = request.user user = request.user
if user.registration.is_admin or user.registration.participates and user.registration.team.pk == kwargs["pk"]: if user.registration.is_admin or user.registration.participates and user.registration.team.pk == kwargs["pk"]:
return super().dispatch(request, *args, **kwargs) return super().get(request, *args, **kwargs)
raise PermissionDenied raise PermissionDenied
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
team = self.object
context["can_validate"] = team.students.count() >= 3 and \
all(r.photo_authorization for r in team.students.all()) and \
team.participation.problem
return context
class TeamUpdateView(LoginRequiredMixin, UpdateView): class TeamUpdateView(LoginRequiredMixin, UpdateView):
model = Team model = Team
@ -148,7 +158,7 @@ class TeamAuthorizationsView(LoginRequiredMixin, DetailView):
_("Photo authorization of {student}.{ext}").format(student=str(student), ext=ext)) _("Photo authorization of {student}.{ext}").format(student=str(student), ext=ext))
zf.close() zf.close()
response = HttpResponse(content_type="application/zip") response = HttpResponse(content_type="application/zip")
response["Content-Disposition"] = "attachment; filename=\"{filename}\""\ response["Content-Disposition"] = "attachment; filename=\"{filename}\"" \
.format(filename=_("Photo authorizations of team {trigram}.zip").format(trigram=team.trigram)) .format(filename=_("Photo authorizations of team {trigram}.zip").format(trigram=team.trigram))
response.write(output.getvalue()) response.write(output.getvalue())
return response return response
@ -172,7 +182,7 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
user = request.user user = request.user
if not self.get_object().valid: if not self.get_object().valid:
raise PermissionDenied(_("The team is not validated yet.")) 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)
raise PermissionDenied raise PermissionDenied
@ -185,7 +195,7 @@ class UploadVideoView(LoginRequiredMixin, UpdateView):
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
user = request.user user = request.user
if user.registration.is_admin or user.registration.participates\ if user.registration.is_admin or user.registration.participates \
and user.registration.team.participation.pk == self.get_object().participation.pk: and user.registration.team.participation.pk == self.get_object().participation.pk:
return super().dispatch(request, *args, **kwargs) return super().dispatch(request, *args, **kwargs)
raise PermissionDenied raise PermissionDenied

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-10-11 15:58+0200\n" "POT-Creation-Date: 2020-10-11 16:27+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"
@ -223,9 +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:27 #: apps/participation/templates/participation/team_detail.html:28
#: apps/participation/templates/participation/team_detail.html:36 #: apps/participation/templates/participation/team_detail.html:37
#: apps/participation/templates/participation/team_detail.html:41 #: apps/participation/templates/participation/team_detail.html:42
#: 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"
@ -241,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:40 #: apps/participation/templates/participation/team_detail.html:41
msgid "Chosen problem:" msgid "Chosen problem:"
msgstr "Problème choisi :" msgstr "Problème choisi :"
@ -269,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:13 #: apps/participation/templates/participation/team_detail.html:14
msgid "Name:" msgid "Name:"
msgstr "Nom :" msgstr "Nom :"
#: apps/participation/templates/participation/team_detail.html:16 #: apps/participation/templates/participation/team_detail.html:17
msgid "Trigram:" msgid "Trigram:"
msgstr "Trigramme :" msgstr "Trigramme :"
#: apps/participation/templates/participation/team_detail.html:19 #: apps/participation/templates/participation/team_detail.html:20
msgid "Access code:" msgid "Access code:"
msgstr "Code d'accès :" msgstr "Code d'accès :"
#: apps/participation/templates/participation/team_detail.html:22 #: apps/participation/templates/participation/team_detail.html:23
msgid "Coachs:" msgid "Coachs:"
msgstr "Encadrants :" msgstr "Encadrants :"
#: apps/participation/templates/participation/team_detail.html:31 #: apps/participation/templates/participation/team_detail.html:32
msgid "Participants:" msgid "Participants:"
msgstr "Participants :" msgstr "Participants :"
#: apps/participation/templates/participation/team_detail.html:44 #: apps/participation/templates/participation/team_detail.html:45
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:47 #: apps/participation/templates/participation/team_detail.html:48
msgid "Authorizations:" msgid "Authorizations:"
msgstr "Autorisations :" msgstr "Autorisations :"
#: apps/participation/templates/participation/team_detail.html:53 #: apps/participation/templates/participation/team_detail.html:54
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:60 #: apps/participation/templates/participation/team_detail.html:61
#: apps/participation/templates/participation/team_detail.html:73 #: apps/participation/templates/participation/team_detail.html:104
#: 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
@ -310,11 +310,39 @@ msgstr "Pas encore envoyée"
msgid "Update" msgid "Update"
msgstr "Modifier" msgstr "Modifier"
#: apps/participation/templates/participation/team_detail.html:68 #: apps/participation/templates/participation/team_detail.html:70
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:72 #: apps/participation/templates/participation/team_detail.html:77
msgid ""
"Your team has at least 3 members and all photo authorizations were given: "
"the team can be validated."
msgstr ""
"Votre équipe contient au moins 3 personnes et toutes les autorisations de "
"droit à l'image ont été données : l'équipe peut être validée."
#: apps/participation/templates/participation/team_detail.html:79
msgid "Submit my team to validation"
msgstr "Soumettre mon équipe à validation"
#: apps/participation/templates/participation/team_detail.html:84
msgid ""
"Your team must be composed of 3 members and each member must upload its "
"photo authorization."
msgstr ""
"Votre équipe doit être composée de 3 membres et chaque membre doit envoyer "
"son autorisation de droit à l'image."
#: apps/participation/templates/participation/team_detail.html:89
msgid "This team didn't ask for validation yet."
msgstr "L'équipe n'a pas encore demandé à être validée."
#: apps/participation/templates/participation/team_detail.html:95
msgid "Your validation is pending."
msgstr ""
#: apps/participation/templates/participation/team_detail.html:103
msgid "Update team" msgid "Update team"
msgstr "Modifier l'équipe" msgstr "Modifier l'équipe"
@ -336,26 +364,25 @@ msgstr "Vous êtes déjà dans une équipe."
msgid "Join team" msgid "Join team"
msgstr "Rejoindre une équipe" msgstr "Rejoindre une équipe"
#: apps/participation/views.py:86 apps/participation/views.py:164 #: apps/participation/views.py:86 apps/participation/views.py:172
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:87 apps/participation/views.py:165 #: apps/participation/views.py:87 apps/participation/views.py:173
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 #: apps/participation/views.py:156 apps/registration/views.py:213
#, python-brace-format #, python-brace-format
msgid "Photo authorization of {student}.{ext}" msgid "Photo authorization of {student}.{ext}"
msgstr "Autorisation de droit à l'image de {student}.{ext}" msgstr "Autorisation de droit à l'image de {student}.{ext}"
#: apps/participation/views.py:152 #: apps/participation/views.py:160
#, fuzzy, python-brace-format #, python-brace-format
#| msgid "Photo authorization of {student}.{ext}"
msgid "Photo authorizations of team {trigram}.zip" msgid "Photo authorizations of team {trigram}.zip"
msgstr "Autorisation de droit à l'image de {student}.{ext}" msgstr "Autorisations de droit à l'image de l'équipe {trigram}.zip"
#: apps/participation/views.py:174 #: apps/participation/views.py:182
msgid "The team is not validated yet." msgid "The team is not validated yet."
msgstr "L'équipe n'est pas encore validée." msgstr "L'équipe n'est pas encore validée."