diff options
author | Alban Gruin | 2018-01-17 12:34:11 +0100 |
---|---|---|
committer | Alban Gruin | 2018-01-17 12:43:02 +0100 |
commit | a2fcd4c7c42b6c02ff8ff7dac4aa23b3d17407de (patch) | |
tree | 8316d0f78e4e9b73a014af7596357edb003446e0 | |
parent | b55297c4d0de64501a6baf3b1f255210de492e97 (diff) |
Base du formulaire de QSJPS
-rw-r--r-- | forms.py | 21 | ||||
-rw-r--r-- | templates/form_qsjps.html | 10 | ||||
-rw-r--r-- | urls.py | 3 | ||||
-rw-r--r-- | views.py | 20 |
4 files changed, 52 insertions, 2 deletions
diff --git a/forms.py b/forms.py new file mode 100644 index 0000000..34081c0 --- /dev/null +++ b/forms.py @@ -0,0 +1,21 @@ +# Copyright (C) 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 +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# celcatsanitizer is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with celcatsanitizer. If not, see <http://www.gnu.org/licenses/>. + +from django import forms + + +class QSJPSForm(forms.Form): + begin = forms.DateTimeField(label="Début") + end = forms.DateTimeField(label="Fin") diff --git a/templates/form_qsjps.html b/templates/form_qsjps.html new file mode 100644 index 0000000..2d97a89 --- /dev/null +++ b/templates/form_qsjps.html @@ -0,0 +1,10 @@ +{% extends "index.html" %} + +{% block title %}QSJPS – {% endblock %} + +{% block body %} + <form action="{% url "qsjps" %}" method="post"> + {{ form }} + <input type="submit" value="Trouver une salle" /> + </form> +{% endblock %} @@ -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 @@ -20,6 +20,7 @@ urlpatterns = [ url(r"^$", views.index, name="index"), url(r"^pages/", include("django.contrib.flatpages.urls")), url(r"^salles/$", views.rooms, name="rooms"), + url(r"^salles/qsjps$", views.qsjps, name="qsjps"), url(r"^salles/(?P<room_slug>[-\w]+)/$", views.room_timetable, name="room-timetable"), url(r"^salles/(?P<room_slug>[-\w]+)/(?P<year>[0-9]{4})/(?P<week>[0-4]?[0-9]|5[0-3])$", views.room_timetable, name="room-timetable"), url(r"^(?P<year_slug>[-\w]+)/$", views.mention_list, name="mentions"), @@ -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} |