Exemple #1
0
def fetch_open_now_for_campus(
                            request, campus, use_cache=True,
                            fill_cache=False, cache_period=FIVE_MINUTE_CACHE):
    if campus is None:
        # Default to zooming in on the UW Seattle campus
        center_latitude = '47.655003'
        center_longitude = '-122.306864'
        zoom_level = '15'
        distance = '500'

    else:
        location = settings.SS_LOCATIONS[campus]
        center_latitude = location['CENTER_LATITUDE']
        center_longitude = location['CENTER_LONGITUDE']
        zoom_level = location['ZOOM_LEVEL']

        if 'DISTANCE' in location:
            distance = location['DISTANCE']
        else:
            distance = '500'

    # SPOT-1832. Making the distance far enough that center of campus to
    # furthest spot from the center can be found
    distance = 1000
    consumer = oauth2.Consumer(
                            key=settings.SS_WEB_OAUTH_KEY,
                            secret=settings.SS_WEB_OAUTH_SECRET)
    client = oauth2.Client(consumer)

    chain = SearchFilterChain(request)
    search_url_args = []
    search_url_args = chain.url_args(request)
    search_url_args.append({'center_latitude': center_latitude})
    search_url_args.append({'center_longitude': center_longitude})
    search_url_args.append({'open_now': '1'})
    search_url_args.append({'distance': distance})
    search_url_args.append({'limit': '0'})

    return get_space_json(
                        client, search_url_args, use_cache,
                        fill_cache, cache_period)