예제 #1
0
def do_directions(request, response):
    # get request parameters
    start_time = get_start_time(request)
    view_mode = request.get('out', 'html')
    engine = request.get('e', 'o')
    force = request.get('f', '')
    try:
        date = datetime.datetime.strptime(request.get('date', ''), '%Y-%m-%d')
    except:
        date = datetime.date.today() + datetime.timedelta(days=1)
        
    # get from and to (hotel name, attraction name or if not found - address)
    [from_place, from_location] = get_place(request, 'from', 'fll')
    [to_place, to_location] = get_place(request, 'to', 'tll')

    # produce data            
    data = itinerary.get_directions(from_place, from_location, to_place, to_location, date, start_time, engine, force)              
    
    # populate the requested view
    if view_mode == 'none':
        view.empty(response);
    elif view_mode == 'json':
        view.to_json(data, response)
    else:
        view.to_html(data, 'directions', request, response)
예제 #2
0
def do_hotels(request, response, stars = None):
    ratings = rater.get_all()
    if stars is not None:
        hotels = [x for x in place.get_hotels() if int(x.rating) == stars]
        ratings = [x for x in ratings if any([y for y in hotels if y.name == x.hotel_name])]
    data = { 
            'ratings': ratings,
            'title': (_("Hotel rating title N stars") % stars) if stars is not None else _("Hotel rating title") 
            }
    view.to_html(data, 'hotels', request, response)
예제 #3
0
def do_place(request, response):
    # get request parameters        
    view_mode = request.get('out', 'html')
    term = request.get('term', '')
    
    # produce data        
    data = place.get(term)
    
    # populate the requested view
    if view_mode == 'json':
        view.to_json(data, response)
    else:
        view.to_html(data, 'hotel', request, response)
예제 #4
0
def do_train(request, response):
    # get request parameters
    view_mode = request.get('out', 'html')

    # produce data        
    tomorrow = datetime.date.today() + datetime.timedelta(days=1)
    data = bot.fetch_trains('Санкт-Петербург', 'Новый Петергоф', tomorrow)
        
    # populate the requested view
    if view_mode == 'json':
        view.to_json(data, response)
    else:
        view.to_html(data, 'train', request, response)
예제 #5
0
def do_routing(request, response):
    # get request parameters
    from_location = maps.common.GeoPoint(*[float(x) for x in request.get('from').split(',')])
    to_location = maps.common.GeoPoint(*[float(x) for x in request.get('to').split(',')])    
    view_mode = request.get('out', 'html')

    # produce data        
    data = maps.router.get_route(from_location, to_location)
        
    # populate the requested view
    if view_mode == 'json':
        view.to_json(data, response)
    else:
        view.to_html(data, 'routing', request, response)    
예제 #6
0
def do_transit(request, response):
    # get request parameters    
    view_mode = request.get('out', 'html')
    try:
        from_location = maps.common.GeoPoint(*[float(x) for x in request.get('from').split(',')])
        to_location = maps.common.GeoPoint(*[float(x) for x in request.get('to').split(',')])    

        # produce data        
        data = maps.engine.get_rusavtobus_routes(from_location, to_location) + maps.engine.get_google_routes(from_location, to_location)
    except:
        data = None
        
    # populate the requested view
    if view_mode == 'json':
        view.to_json(data, response)
    else:
        view.to_html(data, 'transit', request, response)    
예제 #7
0
def do_hotel(request, response, name):
    hotel = place.get(name)[0]
    ratings = rater.get(hotel)
    data = { 'hotel': hotel, 'ratings': ratings }
    view.to_html(data, 'hotel', request, response)
예제 #8
0
def do_notfound(request, response):
    view.to_html(None, 'notfound', request, response)
예제 #9
0
def do_about(request, response):
    view.to_html(None, 'about' if utils.get_language() != 'ru' else 'about_ru', request, response)
예제 #10
0
def do_booking(request, response):
    view.to_html(None, 'booking' if utils.get_language() != 'ru' else 'booking_ru', request, response)
예제 #11
0
def do_home(request, response):
    view.to_html(None, 'home', request, response)
예제 #12
0
def do_about(request, response):
    view.to_html(None, 'about', request, response)