diff --git a/roofis2/roomservice/views.py b/roofis2/roomservice/views.py index 0a7d683..4967da9 100644 --- a/roofis2/roomservice/views.py +++ b/roofis2/roomservice/views.py @@ -1,12 +1,13 @@ from django.shortcuts import render -from roomservice.models import Room +from roomservice.models import Room, Booking import logging +import datetime logger = logging.getLogger(__name__) # Create your views here. def home(request): rooms = Room.objects.all() - return render(request, 'search.jinja', {"title":"rooF(i)S is love rooF(i)S is live!!", "rooms":rooms}) + return render(request, 'search.jinja', {"title":"rooF(i)S is love rooF(i)S is live!!", "rooms": rooms}) def booking(request): @@ -14,7 +15,38 @@ def booking(request): room = Room.objects.get(id=room_id) logger.info(room_id) logger.info(room) - return render(request, 'booking.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!","room":room}) + startdate = datetime.date.today() + weekday = startdate.weekday() + enddate = startdate + datetime.timedelta(7) + multd = [[]] + bookings = Booking.objects.filter(room_id=room.id, start_date__gte=startdate, end_date__lte=enddate) + for booking in bookings: + sdate = booking.start_date + edate = booking.end_date + stime = booking.start_time.hour() + etime = booking.end_time.hour()+1 + if edate != sdate: + break + else: + if weekday == 0: + day = "Monday" + elif weekday == 1: + day = "Tuesday" + elif weekday == 2: + day = "Wednesday" + elif weekday == 3: + day = "Thursday" + elif weekday == 4: + day = "Friday" + elif weekday == 5: + day = "Saturday" + elif weekday == 6: + day = "Sunday" + timediff = etime - stime + if timediff > 1: + while timediff > 1: + multd.append([day, stime + timediff]) + return render(request, 'booking.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!", "multd":multd}) def admin(request): diff --git a/roofis2/templates/booking.jinja b/roofis2/templates/booking.jinja index f68d9ea..cb9da74 100644 --- a/roofis2/templates/booking.jinja +++ b/roofis2/templates/booking.jinja @@ -1,5 +1,8 @@ {% extends 'base.jinja' %} {% block content %} +{% for day in multd%} + $("#"+day[0]+"-"+day[1]).css("background-color", "red"); +{% endfor %} @@ -12,157 +15,147 @@ - + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - - + + + + + + +
Saturday Sunday
6:00 - 7:00
7:00 - 8:00
8:00 - 9:00
9:00 - 10:00
10:00 - 11:00
11:00 - 12:00
12:00 - 13:00
13:00 - 14:00
14:00 - 15:00
15:00 - 16:00
16:00 - 17:00
17:00 - 18:00
18:00 - 19:00
19:00 - 20:00
20:00 - 6:00