1
0
mirror of https://gitlab.com/animath/si/plateforme-corres2math.git synced 2024-12-05 01:26:54 +00:00

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" %}
{% load i18n %}
{% load crispy_forms_filters %}
{% block content %}
@ -61,16 +62,42 @@
</div>
</div>
{% if team.participation.valid %}
<hr>
<hr>
{% if team.participation.valid %}
<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 #}
{% elif team.participation.valid is None %} {# Team did not ask for validation #}
{% 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 %}
{% trans "Update team" as modal_title %}

View File

@ -90,12 +90,22 @@ class MyTeamDetailView(LoginRequiredMixin, RedirectView):
class TeamDetailView(LoginRequiredMixin, DetailView):
model = Team
def dispatch(self, request, *args, **kwargs):
def get(self, request, *args, **kwargs):
user = request.user
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
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):
model = Team
@ -148,7 +158,7 @@ class TeamAuthorizationsView(LoginRequiredMixin, DetailView):
_("Photo authorization of {student}.{ext}").format(student=str(student), ext=ext))
zf.close()
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))
response.write(output.getvalue())
return response
@ -172,7 +182,7 @@ class ParticipationDetailView(LoginRequiredMixin, DetailView):
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"]:
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied
@ -185,7 +195,7 @@ class UploadVideoView(LoginRequiredMixin, UpdateView):
def dispatch(self, request, *args, **kwargs):
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:
return super().dispatch(request, *args, **kwargs)
raise PermissionDenied

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Corres2math\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"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -223,9 +223,9 @@ msgid "Join"
msgstr "Rejoindre"
#: apps/participation/templates/participation/participation_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/participation/templates/participation/team_detail.html:28
#: apps/participation/templates/participation/team_detail.html:37
#: apps/participation/templates/participation/team_detail.html:42
#: apps/registration/templates/registration/user_detail.html:6
#: apps/registration/templates/registration/user_detail.html:26
msgid "any"
@ -241,7 +241,7 @@ msgid "Team:"
msgstr "Équipe :"
#: 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:"
msgstr "Problème choisi :"
@ -269,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:13
#: apps/participation/templates/participation/team_detail.html:14
msgid "Name:"
msgstr "Nom :"
#: apps/participation/templates/participation/team_detail.html:16
#: apps/participation/templates/participation/team_detail.html:17
msgid "Trigram:"
msgstr "Trigramme :"
#: apps/participation/templates/participation/team_detail.html:19
#: apps/participation/templates/participation/team_detail.html:20
msgid "Access code:"
msgstr "Code d'accès :"
#: apps/participation/templates/participation/team_detail.html:22
#: apps/participation/templates/participation/team_detail.html:23
msgid "Coachs:"
msgstr "Encadrants :"
#: apps/participation/templates/participation/team_detail.html:31
#: apps/participation/templates/participation/team_detail.html:32
msgid "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:"
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:"
msgstr "Autorisations :"
#: apps/participation/templates/participation/team_detail.html:53
#: apps/participation/templates/participation/team_detail.html:54
msgid "Not uploaded yet"
msgstr "Pas encore envoyée"
#: apps/participation/templates/participation/team_detail.html:60
#: apps/participation/templates/participation/team_detail.html:73
#: apps/participation/templates/participation/team_detail.html:61
#: apps/participation/templates/participation/team_detail.html:104
#: apps/participation/templates/participation/update_team.html:12
#: apps/registration/templates/registration/update_user.html:12
#: apps/registration/templates/registration/user_detail.html:64
@ -310,11 +310,39 @@ msgstr "Pas encore envoyée"
msgid "Update"
msgstr "Modifier"
#: apps/participation/templates/participation/team_detail.html:68
#: apps/participation/templates/participation/team_detail.html:70
msgid "Access to team participation"
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"
msgstr "Modifier l'équipe"
@ -336,26 +364,25 @@ msgstr "Vous êtes déjà dans une équipe."
msgid "Join team"
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."
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."
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
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}"
#: apps/participation/views.py:160
#, python-brace-format
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."
msgstr "L'équipe n'est pas encore validée."