Beispiel #1
0
def user_unfollow(request, username):
    """
    Unfollow the user
    """
    user = get_object_or_404(User, username=username)
    if request.method == 'POST':
        Follow.unfollow(user, request.user)

    return HttpResponseRedirect(user.get_absolute_url())
Beispiel #2
0
def user_unfollow(request, username):
    """
    Unfollow the user
    """
    user = get_object_or_404(User, username=username)
    if request.method == 'POST':
        Follow.unfollow(user, request.user)        
    
    return HttpResponseRedirect(user.get_absolute_url())
Beispiel #3
0
def user_snippets(request, username, page_index=0, sort_by_new=False):
    """
    Display snippets of particular user
    """
    page_index = int(page_index)
    active = 'new' if sort_by_new else 'top'
    try:
        user = User.get_by_username(username)
    except User.DoesNotExist:
        raise Http404()
    is_follower = request.user.is_authenticated() and Follow.is_follower(user, request.user)
    snippets = Snippet.user_snippets(user, request.user, page_index, settings.PAGE_SIZE, sort_by_new)
    prev_url, next_url = paginated_url(request.resolver_match.url_name, snippets, [username, page_index])

    return render_response(request, 'app/user_snippets.html', locals())
Beispiel #4
0
def user_snippets(request, username, page_index=0, sort_by_new=False):
    """
    Display snippets of particular user
    """
    page_index = int(page_index)
    active = 'new' if sort_by_new else 'top'
    try:
        user = User.get_by_username(username)
    except User.DoesNotExist:
        raise Http404()
    is_follower = request.user.is_authenticated() and Follow.is_follower(
        user, request.user)
    snippets = Snippet.user_snippets(user, request.user, page_index,
                                     settings.PAGE_SIZE, sort_by_new)
    prev_url, next_url = paginated_url(request.resolver_match.url_name,
                                       snippets, [username, page_index])

    return render_response(request, 'app/user_snippets.html', locals())