コード例 #1
0
def display():
    """
    search for busy times of the selected calendars
    assumes authorization and appropriate credentials 
    this far in the process
    """
    app.logger.debug("In the 'display' function")
    cal_service = get_gcal_service(valid_credentials())

    # repopulate calendars list
    flask.g.calendars = flask.session['calendars']

    # time-ordered events lists
    flask.g.busy_events = []
    flask.g.free_events = []
    flask.g.thin_free_events = []
    # gets the selected checkBoxes' ids
    checkBox_id_list = flask.request.form.getlist("calendar")
    for cal_id in checkBox_id_list:
        # get calendar's events
        events = list_events(cal_service, cal_id)
        app.logger.debug("events: ")
        app.logger.debug(events)
        # get events in correct time
        order = time_order(events)
        flask.g.busy_events.append(order)

        free_events = calculate_free(order, flask.session['begin_datetime'],
                                     flask.session['end_datetime'])

        app.logger.debug("free_events: " + str(free_events))
        flask.g.free_events.append(free_events)

    return render_template('index.html')
コード例 #2
0
def test_two_blocks():
	"""
	Tests a list of two busy times.
	"""
	busy_times = [{ 'start': '2017-11-09T10:00:00-08:00', 'end': '2017-11-09T11:00:00-08:00'}, {'start': '2017-11-09T12:30:00-08:00', 'end': '2017-11-09T13:00:00-08:00'}]
	start_time = '2017-11-09T10:30:00-08:00'
	end_time = '2017-11-09T16:00:00-08:00'
	free_times = [['2017-11-09T11:00:00-08:00' , '2017-11-09T12:30:00-08:00'], ['2017-11-09T13:00:00-08:00', '2017-11-09T16:00:00-08:00']]

	assert calculate_free(busy_times, start_time, end_time) == free_times
コード例 #3
0
def test_free_cover():
	"""
	Free block covers busy block.
	"""
	busy_times = [{ 'start': '2017-11-09T10:00:00-08:00', 'end': '2017-11-09T11:20:00-08:00'}]
	start_time = '2017-11-09T08:00:00-08:00'
	end_time = '2017-11-09T12:00:00-08:00'
	free_times = [['2017-11-09T08:00:00-08:00', '2017-11-09T10:00:00-08:00'], ['2017-11-09T11:20:00-08:00', '2017-11-09T12:00:00-08:00']]

	assert calculate_free(busy_times, start_time, end_time) == free_times
コード例 #4
0
def test_all_overlap():
	"""
	Busy block totally covers free block.
	"""
	busy_times = [{ 'start': '2017-11-09T12:30:00-08:00', 'end': '2017-11-09T16:00:00-08:00'}]
	start_time = '2017-11-09T12:30:00-08:00'
	end_time = '2017-11-09T16:00:00-08:00'
	free_times = []

	assert calculate_free(busy_times, start_time, end_time) == free_times
コード例 #5
0
def test_end_overlap():
	"""
	Start of busy block overlaps end of free block.
	"""
	busy_times = [{ 'start': '2017-11-09T12:30:00-08:00', 'end': '2017-11-09T16:00:00-08:00'}]
	start_time = '2017-11-09T10:00:00-08:00'
	end_time = '2017-11-09T14:00:00-08:00'
	free_times = [['2017-11-09T10:00:00-08:00', '2017-11-09T12:30:00-08:00']]

	assert calculate_free(busy_times, start_time, end_time) == free_times
コード例 #6
0
def test_no_overlap():
	"""
	Busy block does not over lap free block.
	"""
	busy_times = [{ 'start': '2017-11-09T10:00:00-08:00', 'end': '2017-11-09T11:20:00-08:00'}]
	start_time = '2017-11-09T08:00:00-08:00'
	end_time = '2017-11-09T09:00:00-08:00'
	free_times = [['2017-11-09T08:00:00-08:00', '2017-11-09T09:00:00-08:00']]

	assert calculate_free(busy_times, start_time, end_time) == free_times