aboutsummaryrefslogtreecommitdiff
path: root/views.py
diff options
context:
space:
mode:
authorAlban Gruin2018-01-17 12:34:11 +0100
committerAlban Gruin2018-01-17 12:43:02 +0100
commita2fcd4c7c42b6c02ff8ff7dac4aa23b3d17407de (patch)
tree8316d0f78e4e9b73a014af7596357edb003446e0 /views.py
parentb55297c4d0de64501a6baf3b1f255210de492e97 (diff)
Base du formulaire de QSJPS
Diffstat (limited to 'views.py')
-rw-r--r--views.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/views.py b/views.py
index 97a1d28..e8fc259 100644
--- a/views.py
+++ b/views.py
@@ -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}