def index(request): client = FacebookClient(request.access_token) friends = client.get_friends() friends.sort(key=(lambda x: x['name'])) if friends: for f in friends: try: u = User.objects.get(username=f['uid']) f['our_user'] = True except: f['our_user'] = False return render_to_response("index.html", {'friends' : friends})
def invite_user(request, user_id): client = FacebookClient(request.access_token) friends = client.get_friends() invited = "" for f in friends: try: u = User.objects.get(username=f['uid']) f['our_user'] = True except: f['our_user'] = False for f in friends: if(f['uid'] == int(user_id)): invited = f['name'] template_context = {'friends' : friends, 'invited' : invited} return render_to_response("index.html", template_context)