This commit is contained in:
Łukasz Jędyk 2019-01-23 12:22:27 +01:00
parent 646e675910
commit ffd81453b7
7 changed files with 3 additions and 2 deletions

0
hotel/manage.py Executable file → Normal file
View File

View File

@ -3,6 +3,7 @@ from django.template import loader
from django.shortcuts import get_object_or_404, render
from .models import *
from .forms import *
from django.db.models import Q
import re
import datetime
@ -29,8 +30,8 @@ def reservation(request):
template = loader.get_template('reservation.html')
error = ""
reservation = Reservation.objects.filter(room_number=room_number).filter(begin_date__gte=begin_date).filter(end_date__lte=end_date)
if reservation:
reservation = Reservation.objects.filter(room_number=room_number).filter(Q(begin_date__range=(begin_datetime, end_datetime)) | Q(end_date__range=(begin_datetime, end_datetime))).first()
if not reservation is None:
status = "Pokój " + str(room_number) + " jest już zarezerwowany"
return HttpResponse(template.render({'status': status}, request))