(target, request, show=None)
return posts
Return post list belonging to a user
Return post list belonging to a user
Return post list belonging to a user
def get_post_list(target, request, show=None):
    """
    Return post list belonging to a user
    """
    user = request.user
    page = request.GET.get("page", 1)
    posts = Post.objects.valid_posts(u=user, author=target)

    # Show a specific post listing.
    show_map = dict(questions=Post.QUESTION, tools=Post.TOOL, news=Post.NEWS,
                    blogs=Post.BLOG, tutorials=Post.TUTORIAL, answers=Post.ANSWER,
                    comments=Post.COMMENT, forum=Post.FORUM)

    type_filter = show_map.get(show)
    posts = posts.filter(type=type_filter) if type_filter is not None else posts

    posts = posts.select_related("root").select_related("author__profile", "lastedit_user__profile")
    posts = posts.order_by("-rank")

    # Cache the users posts add pagination to posts.
    paginator = Paginator(object_list=posts, per_page=settings.POSTS_PER_PAGE)
    posts = paginator.get_page(page)

    return posts
def get_post_list ( target , request , show = None ) : user = request . user page = request . GET . get ( "page" , 1 ) posts = Post . objects . valid_posts ( u = user , author = target ) # Show a specific post listing. show_map = dict ( questions = Post . QUESTION , tools = Post . TOOL , news = Post . NEWS , blogs = Post . BLOG , tutorials = Post . TUTORIAL , answers = Post . ANSWER , comments = Post . COMMENT , forum = Post . FORUM ) type_filter = show_map . get ( show ) posts = posts . filter ( type = type_filter ) if type_filter is not None else posts posts = posts . select_related ( "root" ) . select_related ( "author__profile" , "lastedit_user__profile" ) posts = posts . order_by ( "-rank" ) # Cache the users posts add pagination to posts. paginator = Paginator ( object_list = posts , per_page = settings . POSTS_PER_PAGE ) posts = paginator . get_page ( page ) return posts