Beispiel #1
0
def post_count_box(post, context='', topic=''):
    "Displays the count box for a post row"
    topic = Tag.fixcase(topic)
    topic = topic.split('+')
    if LATEST in topic:
        topic.remove(LATEST)
    return dict(post=post, context=context, topic=topic)
Beispiel #2
0
def posts_by_topic(request, topic):
    "Returns a post query that matches a topic"

    # One letter tags are always uppercase
    topic = Tag.fixcase(topic)

    if topic == MYTAGS:
        # Get the posts that the user wrote.
        # TODO: convert My Tags to Tags Search  'Posts matching the <b><i class="fa fa-tag"></i> Tags Search</b> ')
        #return Post.objects.tag_search(x)
        pass

    if topic == UNANSWERED:
        # Get unanswered posts.
        return Post.objects.top_level().filter(type=Post.QUESTION, reply_count=0).exclude(is_fake_test_data=True)

    if topic in POST_TYPES:
        # A post type.
        return Post.objects.top_level().filter(type=POST_TYPES[topic]).exclude(is_fake_test_data=True)

    if topic and topic != LATEST:
        return Post.objects.tag_search(topic)

    # Return latest by default.
    return Post.objects.top_level()
def post_count_box(post, context='', topic=''):
    "Displays the count box for a post row"
    topic = Tag.fixcase(topic)
    topic = topic.split('+')
    if LATEST in topic:
        topic.remove(LATEST)
    return dict(post=post, context=context, topic=topic)
Beispiel #4
0
def posts_by_topic(request, topic):
    "Returns a post query that matches a topic"
    user = request.user

    # One letter tags are always uppercase
    topic = Tag.fixcase(topic)

    if topic == MYPOSTS:
        # Get the posts that the user wrote.
        return Post.objects.my_posts(target=user, user=user)

    if topic == MYTAGS:
        # Get the posts that the user wrote.
        messages.success(
            request,
            'Posts matching the <b><i class="fa fa-tag"></i> My Tags</b> setting in your user profile'
        )
        return Post.objects.tag_search(user.profile.my_tags)

    if topic == UNANSWERED:
        # Get unanswered posts.
        return Post.objects.top_level(user).filter(type=Post.QUESTION,
                                                   reply_count=0)

    if topic == FOLLOWING:
        # Get that posts that a user follows.
        messages.success(request, 'Threads that will produce notifications.')
        return Post.objects.top_level(user).filter(subs__user=user)

    if topic == BOOKMARKS:
        # Get that posts that a user bookmarked.
        return Post.objects.my_bookmarks(user)

    if topic in POST_TYPES:
        # A post type.
        return Post.objects.top_level(user).filter(type=POST_TYPES[topic])

    if topic and topic != LATEST:
        # Any type of topic.
        if topic:
            messages.info(
                request,
                "Showing: <code>%s</code> &bull; <a href='/'>reset</a>" %
                topic)
        return Post.objects.tag_search(topic)

    # Return latest by default.
    return Post.objects.top_level(user)
Beispiel #5
0
def posts_by_topic(request, topic):
    "Returns a post query that matches a topic"
    user = request.user

    # One letter tags are always uppercase
    topic = Tag.fixcase(topic)

    if topic == MYPOSTS:
        # Get the posts that the user wrote.
        return Post.objects.my_posts(target=user, user=user)

    if topic == MYTAGS:
        # Get the posts that the user wrote.
        messages.success(request,
                         'Posts matching the <b><i class="fa fa-tag"></i> My Tags</b> setting in your user profile')
        return Post.objects.tag_search(user.profile.my_tags)

    if topic == UNANSWERED:
        # Get unanswered posts.
        return Post.objects.top_level(user).filter(type=Post.QUESTION, reply_count=0)

    if topic == FOLLOWING:
        # Get that posts that a user follows.
        messages.success(request, 'Threads that will produce notifications.')
        return Post.objects.top_level(user).filter(subs__user=user)

    if topic == BOOKMARKS:
        # Get that posts that a user bookmarked.
        return Post.objects.my_bookmarks(user)

    if topic in POST_TYPES:
        # A post type.
        return Post.objects.top_level(user).filter(type=POST_TYPES[topic])

    if topic and topic != LATEST:
        # Any type of topic.
        if '+' in topic:
            messages.info(request,
                          "Filtering by tags: {} - <a href='{}'>Reset</a>".format(
                              ' OR '.join(topic.split('+')), reverse('tag-list')))
        return Post.objects.tag_search(topic)

    # Return latest by default.
    return Post.objects.top_level(user)
Beispiel #6
0
def posts_by_topic(request, topic):
    "Returns a post query that matches a topic"
    user = request.user

    # One letter tags are always uppercase
    topic = Tag.fixcase(topic)

    if topic == MYPOSTS:
        # Get the posts that the user wrote.
        return Post.objects.my_posts(target=user, user=user)

    if topic == MYTAGS:
        # Get the posts that the user wrote.
        messages.success(request,
                         'Post que concuerdan con la sección <b><i class="fa fa-tag"></i> Mis Tags</b> de tu perfil')
        return Post.objects.tag_search(user.profile.my_tags)

    if topic == UNANSWERED:
        # Get unanswered posts.
        return Post.objects.top_level(user).filter(type=Post.QUESTION, reply_count=0)

    if topic == FOLLOWING:
        # Get that posts that a user follows.
        messages.success(request, 'Hilos que darán notificaciones.')
        return Post.objects.top_level(user).filter(subs__user=user)

    if topic == BOOKMARKS:
        # Get that posts that a user bookmarked.
        return Post.objects.my_bookmarks(user)

    if topic in POST_TYPES:
        # A post type.
        return Post.objects.top_level(user).filter(type=POST_TYPES[topic])

    if topic and topic != LATEST:
        # Any type of topic.
        if topic:
            messages.info(request,
                          "Mostrando: <code>%s</code> &bull; <a href='/'>resetear</a>" % topic)
        return Post.objects.tag_search(topic)

    # Return latest by default.
    return Post.objects.top_level(user)