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 55d2b88..8c82bbb 100644 --- a/roofis2/roomservice/views.py +++ b/roofis2/roomservice/views.py @@ -1,5 +1,6 @@ from roomservice.models import Room, Favorite, Booking -from django.shortcuts import render, redirect +import datetime +from django.shortcuts import render import logging logger = logging.getLogger(__name__) @@ -14,9 +15,47 @@ 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) - 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() + logger.info(weekday) + enddate = startdate + datetime.timedelta(7) + 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: + 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 - 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}) def admin(request): diff --git a/roofis2/static/css/style.css b/roofis2/static/css/style.css index ca41812..76e5523 100644 --- a/roofis2/static/css/style.css +++ b/roofis2/static/css/style.css @@ -5,4 +5,10 @@ line-height: 3.5em; vertical-align: middle; padding-left: -1em; +} +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 f68d9ea..c1e5c18 100644 --- a/roofis2/templates/booking.jinja +++ b/roofis2/templates/booking.jinja @@ -1,6 +1,12 @@ {% extends 'base.jinja' %} {% block content %} -
| Time | @@ -12,157 +18,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 | -- | - | - | - | - | - | + | + | + | + | + | + | + |