diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,4 +1,4 @@ -# Copyright (C) 2017 Alban Gruin +# Copyright (C) 2017-2018 Alban Gruin # # celcatsanitizer is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published @@ -19,7 +19,9 @@ from django.db.models import Count, Max from django.db.models.functions import ExtractWeek, ExtractYear, Length from django.http import Http404 from django.shortcuts import get_object_or_404, render +from django.views.decorators.csrf import csrf_exempt +from .forms import QSJPSForm from .models import Course, Group, Room, Timetable, Year from .utils import get_current_week, get_current_or_next_week, get_week, group_courses @@ -144,5 +146,21 @@ def room_timetable(request, room_slug, year=None, week=None): room = get_object_or_404(Room, slug=room_slug) return timetable_common(request, room, year, week) +@csrf_exempt +def qsjps(request): + if request.method == "POST": + # Si on traite un formulaire, on le valide + form = QSJPSForm(request.POST) + if form.is_valid(): + # Formulaire validé + return None + else: + # Formulaire invalide, on le raffiche avec une erreur + return render(request, "form_qsjps.html", {"form": form}) + else: + # Sinon, affichage d’un formulaire vide + form = QSJPSForm() + return render(request, "form_qsjps.html", {"form": form}) + def ctx_processor(request): return {"celcatsanitizer_version": edt.VERSION} |