From be5fa242c6d3a740637679c3625a917c4ccdd0aa Mon Sep 17 00:00:00 2001 From: Tobias Haegele Date: Sat, 9 Jun 2018 06:32:07 +0200 Subject: [PATCH] 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