예제 #1
0
def userline(request, username=None):
    try:
        user = cass.get_user_by_username(username)
    except cass.DatabaseError:
        raise Http404

    # Query for the friend ids
    friend_usernames = []
    if request.user['is_authenticated']:
        friend_usernames = cass.get_friend_usernames(username) + [username]

    # Add a property on the user to indicate whether the currently logged-in
    # user is friends with the user
    user['friend'] = username in friend_usernames

    start = request.GET.get('start')
    tweets, next = cass.get_userline(username, start=start, limit=NUM_PER_PAGE)
    context = {
        'user': user,
        'username': username,
        'tweets': tweets,
        'next': next,
        'friend_usernames': friend_usernames,
    }
    return render_to_response('tweets/userline.html',
                              context,
                              context_instance=RequestContext(request))
예제 #2
0
def userline(request, username=None):
    try:
        user = cass.get_user_by_username(username)
    except cass.DatabaseError:
        raise Http404

    # Query for the friend ids
    friend_usernames = []
    if request.user['is_authenticated']:
        friend_usernames = cass.get_friend_usernames(username) + [username]

    # Add a property on the user to indicate whether the currently logged-in
    # user is friends with the user
    is_friend = username in friend_usernames

    start = request.GET.get('start')
    tweets, next_timeuuid = cass.get_userline(username, start=start, limit=NUM_PER_PAGE)
    context = {
        'user': user,
        'username': username,
        'tweets': tweets,
        'next': next_timeuuid,
        'is_friend': is_friend,
        'friend_usernames': friend_usernames,
    }
    return render_to_response(
        'tweets/userline.html', context, context_instance=RequestContext(request))
예제 #3
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))
예제 #4
0
def userline(request, username=None):
    try:
        user = cass.get_user_by_username(username)
    except cass.DatabaseError:
        raise Http404
    
    # Query for the friend ids
    friend_ids = []
    if request.user['is_authenticated']:
        friend_ids = cass.get_friend_ids(request.user['id']) + [request.user['id']]
    
    # Add a property on the user to indicate whether the currently logged-in
    # user is friends with the user
    user['friend'] = user['id'] in friend_ids
    
    start = request.GET.get('start')
    tweets = cass.get_userline(user['id'], 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 = {
        'user': user,
        'tweets': tweets,
        'next': next,
        'friend_ids': friend_ids,
    }
    return render_to_response('tweets/userline.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():
        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))
예제 #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))
예제 #7
0
def publicline(request):
    start = request.GET.get('start')
    tweets, next_timeuuid = cass.get_userline(
        cass.PUBLIC_USERLINE_KEY, start=start, limit=NUM_PER_PAGE)
    context = {
        'tweets': tweets,
        'next': next_timeuuid,
    }
    return render_to_response(
        'tweets/publicline.html', context, context_instance=RequestContext(request))
예제 #8
0
def publicline(request):
    start = request.GET.get('start')
    tweets, next_timeuuid = cass.get_userline(
        cass.PUBLIC_USERLINE_KEY, start=start, limit=NUM_PER_PAGE)
    context = {
        'tweets': tweets,
        'next': next_timeuuid,
    }
    return render_to_response(
        'tweets/publicline.html', context, context_instance=RequestContext(request))
예제 #9
0
def publicline(request):
    start = request.GET.get('start')
    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 = {
        'tweets': tweets,
        'next': next,
    }
    return render_to_response('tweets/publicline.html', context,
        context_instance=RequestContext(request))
예제 #10
0
def timeline(request):
    form = TweetForm(request.POST or None)
    if request.user['is_authenticated'] and form.is_valid():
        tweet_id = uuid.uuid4()
        cass.save_tweet(tweet_id, request.session['username'], form.cleaned_data['body'])
        return HttpResponseRedirect(reverse('timeline'))
    start = request.GET.get('start')
    if request.user['is_authenticated']:
        tweets, next_timeuuid = cass.get_timeline(
            request.session['username'], start=start, limit=NUM_PER_PAGE)
    else:
        tweets, next_timeuuid = cass.get_userline(
            cass.PUBLIC_USERLINE_KEY, start=start, limit=NUM_PER_PAGE)
    context = {
        'form': form,
        'tweets': tweets,
        'next': next_timeuuid,
    }
    return render_to_response(
        'tweets/timeline.html', context, context_instance=RequestContext(request))
예제 #11
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))