Exemple #1
0
def taggedPosts(request, tag):
    context = RequestContext(request)

    if request.method == 'GET':
        try:
            if request.user.is_authenticated():
                postList = []
                viewer = Author.objects.get(user=request.user)
                posts = post_utils.getVisibleToAuthor(viewer)
                taggedPosts = PostCategory.getPostWithCategory(tag)

                for categorizedPost in taggedPosts:
                    jsonPost = post_utils.get_post_json(categorizedPost.post)
                    if jsonPost in posts:
                        postList.append(jsonPost)

                context['posts'] = _getDetailedPosts(postList)
                context['visibility'] = post_utils.getVisibilityTypes()
                context['page_header'] = 'Posts tagged as %s' % tag
                context['specific'] = True

                return render_to_response('index.html', context)
        except Exception as e:
            print "Error in posts: %s" % e

    return HttpResponseRedirect(request.META.get('HTTP_REFERER'))
Exemple #2
0
def _getAllPosts(viewer, postAuthor=None, time_line=False, remoteOnly=False):
    data = {}

    if remoteOnly:
        post_list = remote_helper.api_getPostByAuthorID(viewer, postAuthor)
        print(len(post_list))
    else:
        post_list = post_utils.getVisibleToAuthor(viewer=viewer,
                                                  author=postAuthor,
                                                  time_line=time_line)
        if viewer is not None:
            post_list.extend(_get_github_events(viewer))

    data['posts'] = _getDetailedPosts(post_list)
    data['visibility'] = post_utils.getVisibilityTypes()

    return data