def get_valid_end_times(request, selected_date, selected_time=None):
    """Given a start_datetime, return an ajax list of end times"""
    if selected_date is None:
        return get_json_str_as_http_response2(request, False, "The start date was not found")
            
    if selected_time is None:
        return get_json_str_as_http_response2(request, False, "The start time was not found")
        
    try:
        time_str = '%s %s' % (selected_date, selected_time)
        selected_datetime = datetime.strptime(time_str, '%Y-%m-%d %H-%M')
    except:
        return get_json_str_as_http_response2(request, False, "The start time was not valid")
        

    timeslot_checker = TimeSlotChecker(selected_date=selected_datetime.date())
    end_time_options = timeslot_checker.get_end_times_for_ajax_call(selected_datetime)
    if end_time_options is None:
        return get_json_str_as_http_response2(request, False, "Sorry!  No end times are available")
    
    options_html = render_to_string_remove_spaces('admin_signup/ajax_end_time_options.html'\
                                , { 'end_time_options' : end_time_options})
    options_html_json = simplejson.dumps(options_html)
    
    return get_json_str_as_http_response2(request, True, msg=''\
                                , json_str=',"options_html" : %s' % options_html_json)
def get_cal_user_contact_info(request, cal_user_id=None):
    if cal_user_id is None:
        return get_json_str_as_http_response2(request, False, "The calendar user id was not found")
         

    try:
        cal_user_to_check = CalendarUser.objects.get(pk=cal_user_id)
    except CalendarUser.DoesNotExist:
        return get_json_str_as_http_response2(request, False, "The calendar user was not found")
    
    contact_info_dict = { 'phone_number' : cal_user_to_check.phone_number
                            ,'email' : cal_user_to_check.contact_email
                            ,'billing_code' : cal_user_to_check.billing_code
                            ,'lab_name': cal_user_to_check.lab_name
                        }  
    json_contact_info = simplejson.dumps(contact_info_dict)
    
    return get_json_str_as_http_response2(request, True, msg=''\
                                , json_str=',"contact_info" : %s' % json_contact_info)