Ejemplo n.º 1
0
def modify_friend(request):
    next = request.REQUEST.get('next')
    added = False
    removed = False
    if request.user['is_authenticated']:
        if 'add-friend' in request.POST:
            cass.add_friends(
                request.session['username'],
                [request.POST['add-friend']]
            )
            added = True
        if 'remove-friend' in request.POST:
            cass.remove_friends(
                request.session['username'],
                [request.POST['remove-friend']]
            )
            removed = True
    if next:
        return HttpResponseRedirect(next)
    context = {
        'added': added,
        'removed': removed,
    }
    return render_to_response('users/modify_friend.html', context,
        context_instance=RequestContext(request))
Ejemplo n.º 2
0
def modify_friend(request):
    next = request.REQUEST.get('next')
    added = False
    removed = False
    if request.user['is_authenticated']:
        if 'add-friend' in request.POST:
            cass.add_friends(
                request.session['username'],
                [request.POST['add-friend']]
            )
            added = True
        if 'remove-friend' in request.POST:
            cass.remove_friends(
                request.session['username'],
                [request.POST['remove-friend']]
            )
            removed = True
    if next:
        return HttpResponseRedirect(next)
    context = {
        'added': added,
        'removed': removed,
    }
    return render_to_response(
        'users/modify_friend.html', context, context_instance=RequestContext(request))
def reset_friends():
    for user in USERS:
        # Remove all friends
        for friend in get_friend_usernames(user):
            remove_friend(user, friend)
        # Add some new friends
        for i in range(randint(1, len(USERS)-1)):
            add_friends(user, [choice(USERS)])