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.FOOD_STYLES[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)