def ajax_search(request): if not request.user.is_authenticated() or 'twitter_tokens' not in request.session: return HttpResponse("") if request.is_ajax(): term = request.GET.get('q') page = request.GET.get('page') if (term is not None and page is not None): api = get_authorized_twython(request.session['twitter_tokens']) statuses = Status.construct_from_search_dicts(api.searchTwitter(q=term, page=page)[u'results']) return render_to_response('twitter/status_list.html', { 'statuses': statuses }, context_instance=RequestContext(request)) return HttpResponse('')
def search(request): if not request.user.is_authenticated() or 'twitter_tokens' not in request.session: return HttpResponseRedirect("/") term = request.GET.get('q') if term is not None: prof = request.user.get_profile() twitter_tokens = request.session['twitter_tokens'] api = get_authorized_twython(twitter_tokens) tp = TwitterUserProfile.objects.get(id=twitter_tokens['user_id']) statuses = Status.construct_from_search_dicts(api.searchTwitter(q=term)[u'results']) friends = api.getFriendsStatus() Rating.appendTo(statuses, tp) return render_to_response('twitter/search_index.html', { # 'whale': prof.whale, 'friends': friends, 'statuses': statuses, 'term': term }, context_instance=RequestContext(request)) else: return HttpResponseRedirect("/")