diff options
Diffstat (limited to 'views.py')
-rw-r--r-- | views.py | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -19,6 +19,7 @@ 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.utils import timezone from django.views.decorators.csrf import csrf_exempt from .forms import QSJPSForm @@ -153,7 +154,18 @@ def qsjps(request): form = QSJPSForm(request.POST) if form.is_valid(): # Formulaire validé - return render(request, "qsjps.html", {"rooms": [], "form": form}) + day = form.cleaned_data["day"] + begin_hour = form.cleaned_data["begin"] + end_hour = form.cleaned_data["end"] + + begin = timezone.make_aware(datetime.datetime.combine(day, + begin_hour)) + end = timezone.make_aware(datetime.datetime.combine(day, end_hour)) + + rooms = Room.objects.qsjps(begin, end) + return render(request, "qsjps.html", {"rooms": rooms, + "form": form}) + # Si le formulaire est invalide, on ré-affiche le formulaire # avec les erreurs else: |