Exemplo n.º 1
0
def check_availability(space_id, room_id, date, start_time, end_time):
    bookings = BookingController()
    slots = SlotsController()
    start = datetime.datetime.strptime(date+' '+start_time, '%Y-%m-%d %H:%M')
    end = datetime.datetime.strptime(date+' '+end_time, '%Y-%m-%d %H:%M')
    slot_id = ('%s %s'%(space_id, room_id)).strip()
    while start < end:
        time = start.strftime('%Y-%m-%d %H:%M')
        start = start + datetime.timedelta(hours=1)
        slot = slots.get_item(slot_id=slot_id, start_time=time)
        if slot:
            return False
    return True