예제 #1
0
def timeline(request):
    form = TweetForm(request.POST or None)
    if request.user['is_authenticated'] and form.is_valid():
        tweet_id = str(uuid.uuid1())
        cass.save_tweet(
            tweet_id, request.session['username'], {
                'username': request.session['username'],
                'body': form.cleaned_data['body'],
            })
        return HttpResponseRedirect(reverse('timeline'))
    start = request.GET.get('start')
    if request.user['is_authenticated']:
        tweets, next = cass.get_timeline(request.session['username'],
                                         start=start,
                                         limit=NUM_PER_PAGE)
    else:
        tweets, next = cass.get_userline(cass.PUBLIC_USERLINE_KEY,
                                         start=start,
                                         limit=NUM_PER_PAGE)
    context = {
        'form': form,
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/timeline.html',
                              context,
                              context_instance=RequestContext(request))
예제 #2
0
def timeline(request):
    form = TweetForm(request.POST or None)
    if request.user['is_authenticated'] and form.is_valid():
        tweet_id = str(uuid.uuid1())
        cass.save_tweet(tweet_id, request.user['id'], {
            'id': tweet_id,
            'user_id': request.user['id'],
            'body': form.cleaned_data['body'],
        })
        return HttpResponseRedirect(reverse('timeline'))
    start = request.GET.get('start')
    if request.user['is_authenticated']:
        tweets = cass.get_timeline(request.user['id'], start=start,
            limit=NUM_PER_PAGE + 1)
    else:
        tweets = cass.get_userline(cass.PUBLIC_USERLINE_KEY, start=start,
            limit=NUM_PER_PAGE + 1)
    next = None
    if tweets and len(tweets) == NUM_PER_PAGE + 1:
        next = tweets[-1]['_ts']
    tweets = tweets[:NUM_PER_PAGE]
    context = {
        'form': form,
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/timeline.html', context,
        context_instance=RequestContext(request))
예제 #3
0
def timeline(request):
   # pdb.set_trace()
#print request.GET['status'] # for GET form method
#print request.POST['status'] # for POST form method
#debug
    try:
        if request.user['is_authenticated'] :
            status_opcode=101
            print request.POST['status'] # for POST form method
            print request.POST['user_id'] # for POST form method
            print request.POST['activibe'] # for POST form method
            user_status  = request.POST['status'] # for POST form method
            user_id      = request.POST['user_id'] # for POST form method
            user_domain  = request.POST['activibe'] # for POST form method
	    if user_domain == 101:
	        cass.save_user_status(user_status,user_id,user_domain)
                #start = request.GET.get('start')
                start=1
                status,next = cass.get_user_status(user_id)
                context = {
                   'status': status,
                   'next': next,
                }
                return render_to_response('tweets/timeline.html', context,
                    context_instance=RequestContext(request))
         #       return HttpResponseRedirect(reverse('timeline'))
	else:
 	    print "Invalid Request"
    except:
        print "Unexpected error:"
#debug

    form = TweetForm(request.POST or None)
    if request.user['is_authenticated'] and form.is_valid():
        tweet_id = str(uuid.uuid1())
        cass.save_tweet(tweet_id, request.session['username'], {
            'username': request.session['username'],
            'body': form.cleaned_data['body'],
        })
        return HttpResponseRedirect(reverse('timeline'))
    start = request.GET.get('start')
    if request.user['is_authenticated']:
        tweets,next = cass.get_timeline(request.session['username'],
            start=start, limit=NUM_PER_PAGE)
        #tweets,next = cass.get_friends(request.session['username'],
         #    limit=NUM_PER_PAGE)
    else:
        tweets,next = cass.get_userline(cass.PUBLIC_USERLINE_KEY, start=start,
            limit=NUM_PER_PAGE)
    context = {
        'form': form,
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/timeline.html', context,
        context_instance=RequestContext(request))
예제 #4
0
def publicline(request):
    start = request.GET.get('start')
    tweets,next = cass.get_timeline(cass.PUBLIC_TIMELINE_KEY, start=start,
        limit=NUM_PER_PAGE)
    context = {
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/publicline.html', context,
        context_instance=RequestContext(request))
예제 #5
0
def timeline(request):
    form = TweetForm(request.POST or None)
    if request.user['is_authenticated'] and form.is_valid():
        cass.save_tweet(request.session['username'], form.cleaned_data['body'])
        return HttpResponseRedirect(reverse('timeline'))
    start = request.GET.get('start')
    if request.user['is_authenticated']:
        tweets,next = cass.get_timeline(request.session['username'],
            start=start, limit=NUM_PER_PAGE)
    else:
        tweets,next = cass.get_timeline(cass.PUBLIC_TIMELINE_KEY, start=start,
            limit=NUM_PER_PAGE)
    context = {
        'form': form,
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/timeline.html', context,
        context_instance=RequestContext(request))
예제 #6
0
def timeline(request):
    # pdb.set_trace()
    #print request.GET['status'] # for GET form method
    #print request.POST['status'] # for POST form method
    #debug
    try:
        if request.user['is_authenticated']:
            status_opcode = 101
            print request.POST['status']  # for POST form method
            print request.POST['user_id']  # for POST form method
            print request.POST['activibe']  # for POST form method
            user_status = request.POST['status']  # for POST form method
            user_id = request.POST['user_id']  # for POST form method
            user_domain = request.POST['activibe']  # for POST form method
            if user_domain == 101:
                cass.save_user_status(user_status, user_id, user_domain)
                #start = request.GET.get('start')
                start = 1
                status, next = cass.get_user_status(user_id)
                context = {
                    'status': status,
                    'next': next,
                }
                return render_to_response(
                    'tweets/timeline.html',
                    context,
                    context_instance=RequestContext(request))
        #       return HttpResponseRedirect(reverse('timeline'))
        else:
            print "Invalid Request"
    except:
        print "Unexpected error:"


#debug

    form = TweetForm(request.POST or None)
    if request.user['is_authenticated'] and form.is_valid():
        tweet_id = str(uuid.uuid1())
        cass.save_tweet(
            tweet_id, request.session['username'], {
                'username': request.session['username'],
                'body': form.cleaned_data['body'],
            })
        return HttpResponseRedirect(reverse('timeline'))
    start = request.GET.get('start')
    if request.user['is_authenticated']:
        tweets, next = cass.get_timeline(request.session['username'],
                                         start=start,
                                         limit=NUM_PER_PAGE)
        #tweets,next = cass.get_friends(request.session['username'],
        #    limit=NUM_PER_PAGE)
    else:
        tweets, next = cass.get_userline(cass.PUBLIC_USERLINE_KEY,
                                         start=start,
                                         limit=NUM_PER_PAGE)
    context = {
        'form': form,
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/timeline.html',
                              context,
                              context_instance=RequestContext(request))