From 7fc5e25cbad75311dc5f3a3e9630470f81e3f5ef Mon Sep 17 00:00:00 2001 From: Tobias Haegele Date: Sat, 9 Jun 2018 04:55:22 +0200 Subject: [PATCH 1/3] pull --- roofis2/roomservice/views.py | 38 +++++- roofis2/templates/booking.jinja | 211 +++++++++++++++----------------- 2 files changed, 137 insertions(+), 112 deletions(-) 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
From 70df3fbea7dc606364c530b304f9e84d963bbe02 Mon Sep 17 00:00:00 2001 From: Tobias Haegele Date: Sat, 9 Jun 2018 05:14:49 +0200 Subject: [PATCH 2/3] push --- roofis2/roomservice/views.py | 4 ++-- roofis2/static/css/style.css | 3 +++ roofis2/templates/booking.jinja | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/roofis2/roomservice/views.py b/roofis2/roomservice/views.py index 041770e..24ce7ba 100644 --- a/roofis2/roomservice/views.py +++ b/roofis2/roomservice/views.py @@ -24,8 +24,8 @@ def booking(request): for booking in bookings: sdate = booking.start_date edate = booking.end_date - stime = booking.start_time.hour() - etime = booking.end_time.hour()+1 + stime = booking.start_time.hour + etime = booking.end_time.hour+1 if edate != sdate: break else: diff --git a/roofis2/static/css/style.css b/roofis2/static/css/style.css index ca41812..f9a528f 100644 --- a/roofis2/static/css/style.css +++ b/roofis2/static/css/style.css @@ -5,4 +5,7 @@ line-height: 3.5em; vertical-align: middle; padding-left: -1em; +} +td{ + background-color: lawngreen; } \ No newline at end of file diff --git a/roofis2/templates/booking.jinja b/roofis2/templates/booking.jinja index cb9da74..01aee26 100644 --- a/roofis2/templates/booking.jinja +++ b/roofis2/templates/booking.jinja @@ -1,7 +1,7 @@ {% extends 'base.jinja' %} {% block content %} {% for day in multd%} - $("#"+day[0]+"-"+day[1]).css("background-color", "red"); + $("#"+day[0] + day[1]-1 + "-" + day[1]).css("background-color", "red"); {% endfor %} From be5fa242c6d3a740637679c3625a917c4ccdd0aa Mon Sep 17 00:00:00 2001 From: Tobias Haegele Date: Sat, 9 Jun 2018 06:32:07 +0200 Subject: [PATCH 3/3] 1 --- .../sample_data_creation/data_creator.py | 2 +- roofis2/roomservice/views.py | 15 +- roofis2/static/css/style.css | 3 + roofis2/templates/booking.jinja | 203 +++++++++--------- 4 files changed, 118 insertions(+), 105 deletions(-) diff --git a/roofis2/roomservice/management/sample_data_creation/data_creator.py b/roofis2/roomservice/management/sample_data_creation/data_creator.py index 75f750f..4bb32b7 100644 --- a/roofis2/roomservice/management/sample_data_creation/data_creator.py +++ b/roofis2/roomservice/management/sample_data_creation/data_creator.py @@ -142,7 +142,7 @@ def create_num_equipment(): def create_access_point(): for i in range(1, 25): access_point, _ = AccessPoint.objects.get_or_create(mac_address=''.join( - random.choices(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'], k=12)), ) + random.choices(['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'], k=12))) for i in range(1, random.randint(1, 4)): access_point.rooms.add(random.choice(Room.objects.all())) access_point.save() diff --git a/roofis2/roomservice/views.py b/roofis2/roomservice/views.py index 24ce7ba..d50cd57 100644 --- a/roofis2/roomservice/views.py +++ b/roofis2/roomservice/views.py @@ -14,18 +14,23 @@ def search(request): def booking(request): room_id = request.POST["room"] room = Room.objects.get(id=room_id) - logger.info(room_id) - logger.info(room) startdate = datetime.date.today() weekday = startdate.weekday() + logger.info(weekday) enddate = startdate + datetime.timedelta(7) - multd = [[]] + multd = [] bookings = Booking.objects.filter(room_id=room.id, start_date__gte=startdate, end_date__lte=enddate) + logger.info(bookings) for booking in bookings: + logger.info(booking) sdate = booking.start_date + logger.info(sdate) edate = booking.end_date + logger.info(edate) stime = booking.start_time.hour + logger.info(stime) etime = booking.end_time.hour+1 + logger.info(etime) if edate != sdate: break else: @@ -46,7 +51,9 @@ def booking(request): timediff = etime - stime if timediff > 1: while timediff > 1: - multd.append([day, stime + timediff]) + multd.append(day+(stime+timediff-1).__str__()+"-"+(stime + timediff).__str__()) + timediff = timediff-1 + logger.info(multd) return render(request, 'booking.jinja', {"title": "rooF(i)S is love rooF(i)S is live!!", "multd":multd}) diff --git a/roofis2/static/css/style.css b/roofis2/static/css/style.css index f9a528f..76e5523 100644 --- a/roofis2/static/css/style.css +++ b/roofis2/static/css/style.css @@ -8,4 +8,7 @@ } td{ background-color: lawngreen; +} +.booked{ + background-color: red; } \ No newline at end of file diff --git a/roofis2/templates/booking.jinja b/roofis2/templates/booking.jinja index 01aee26..c1e5c18 100644 --- a/roofis2/templates/booking.jinja +++ b/roofis2/templates/booking.jinja @@ -1,9 +1,12 @@ {% extends 'base.jinja' %} {% block content %} {% for day in multd%} - $("#"+day[0] + day[1]-1 + "-" + day[1]).css("background-color", "red"); + {% endfor %} -
+
@@ -19,143 +22,143 @@ - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + + - - - - - - - + + + + + + +
Time
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