def decide(request):
    you = User(request.user.username, request.user.password)
    result = API.places_decide(you, request.GET['latitude'],
                               request.GET['longitude'])
    if not result:
        logout(request)
        return HttpResponseResult(reverse('single.decide'))

    reasons = []
    for reason in result['reasons']:
        if reason.startswith('like:'):
            reasons.append('You like %s.' % settings.get_food_style(reason[5:]))
        elif reason == 'distance':
            reasons.append("It's nearby.")
        elif reason == 'great_rating':
            reasons.append("It has a great rating of %.1f stars on Yelp." % result['stars'])
        elif reason == 'good_rating':
            reasons.append('It has a good rating of %.1f stars on Yelp.' % result['stars'])
        elif reason == 'notrecent':
            reasons.append("We haven't suggested this to you in a while.")

    data = { 'decision': result['business']['name'],
             'reasons': reasons,
             'latitude': result['business']['location']['coordinate']['latitude'],
             'longitude': result['business']['location']['coordinate']['longitude'],
             'address': result['business']['location']['display_address'],
             'phone': result['business']['display_phone']}
    return jingo.render(request, 'single/decide.html', data)
def get_questions(request):
    you = User(request.user.username, request.user.password)
    response = API.taste_query(you, request.POST['latitude'],
                               request.POST['longitude'])
    if not response:
        logout(request)
        return HttpResponseRedirect(reverse('single.get_questions'))

    if response['result'] != 'okay':
        return HttpResponse(json.dumps(response))

    clean_names = [settings.get_food_style(i) for i in response['tastes']]

    response['tastes_pretty'] = clean_names[:response['to_ask']]

    return HttpResponse(json.dumps(response))