From acb718cdc068aad17535fc0bc0d6f2e69037f5c5 Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Sun, 11 Oct 2020 17:24:23 +0200 Subject: [PATCH] Request validation is working --- .../templates/participation/team_detail.html | 7 +++++-- apps/participation/views.py | 10 ++++++++++ locale/fr/LC_MESSAGES/django.po | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/apps/participation/templates/participation/team_detail.html b/apps/participation/templates/participation/team_detail.html index 04ccb6a..89471ab 100644 --- a/apps/participation/templates/participation/team_detail.html +++ b/apps/participation/templates/participation/team_detail.html @@ -70,13 +70,16 @@ {% trans "Access to team participation" %} - {% elif team.participation.valid is None %} {# Team did not ask for validation #} + {% elif team.participation.valid == None %} {# Team did not ask for validation #} {% if user.registration.participates %} {% if can_validate %}
{% trans "Your team has at least 3 members and all photo authorizations were given: the team can be validated." %}
- +
+ {% csrf_token %} + +
{% else %} diff --git a/apps/participation/views.py b/apps/participation/views.py index b0f5336..1989620 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -1,6 +1,8 @@ from io import BytesIO from zipfile import ZipFile +from django.shortcuts import redirect + from corres2math.lists import get_sympa_client from django.contrib.auth.mixins import LoginRequiredMixin from django.core.exceptions import PermissionDenied @@ -96,6 +98,14 @@ class TeamDetailView(LoginRequiredMixin, DetailView): return super().get(request, *args, **kwargs) raise PermissionDenied + def post(self, request, *args, **kwargs): + if request.user.registration.participates: + if "request-validation" in request.POST: + request.user.registration.team.participation.valid = False + # TODO Send mail to admins + request.user.registration.team.participation.save() + return redirect(request.path) + def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 9f785fa..ea110aa 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -340,7 +340,7 @@ 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 "" +msgstr "Votre validation est en attente." #: apps/participation/templates/participation/team_detail.html:103 msgid "Update team"