diff --git a/hotel/manage.py b/hotel/manage.py old mode 100755 new mode 100644 diff --git a/hotel/rooms/__pycache__/admin.cpython-36.pyc b/hotel/rooms/__pycache__/admin.cpython-36.pyc index e1f84ff..0eb562e 100644 Binary files a/hotel/rooms/__pycache__/admin.cpython-36.pyc and b/hotel/rooms/__pycache__/admin.cpython-36.pyc differ diff --git a/hotel/rooms/__pycache__/models.cpython-36.pyc b/hotel/rooms/__pycache__/models.cpython-36.pyc index 815db6a..fdca877 100644 Binary files a/hotel/rooms/__pycache__/models.cpython-36.pyc and b/hotel/rooms/__pycache__/models.cpython-36.pyc differ diff --git a/hotel/rooms/__pycache__/urls.cpython-36.pyc b/hotel/rooms/__pycache__/urls.cpython-36.pyc index 62808f2..903b147 100644 Binary files a/hotel/rooms/__pycache__/urls.cpython-36.pyc and b/hotel/rooms/__pycache__/urls.cpython-36.pyc differ diff --git a/hotel/rooms/__pycache__/views.cpython-36.pyc b/hotel/rooms/__pycache__/views.cpython-36.pyc index 95ed9b7..37dd770 100644 Binary files a/hotel/rooms/__pycache__/views.cpython-36.pyc and b/hotel/rooms/__pycache__/views.cpython-36.pyc differ diff --git a/hotel/rooms/migrations/__pycache__/0006_remove_room_reserved.cpython-36.pyc b/hotel/rooms/migrations/__pycache__/0006_remove_room_reserved.cpython-36.pyc new file mode 100644 index 0000000..1ae7e9f Binary files /dev/null and b/hotel/rooms/migrations/__pycache__/0006_remove_room_reserved.cpython-36.pyc differ diff --git a/hotel/rooms/views.py b/hotel/rooms/views.py index 336e2bf..fe439ae 100644 --- a/hotel/rooms/views.py +++ b/hotel/rooms/views.py @@ -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))