예제 #1
0
def home(request):
    posts = Post.objects.filter(parent__isnull=True)
    context = {
        'posts': get_paginated(request, posts),
        'breadcrumbs': home_breadcrumbs(),
    }
    return render_to_response("posts/home.html", context, context_instance = RequestContext(request))
예제 #2
0
def profile(request, username):
    this_user = get_object_or_404(User, username=username)
    posts = Post.objects.filter(user=this_user)
    context = {
        'this_user': this_user,
        'posts': get_paginated(request, posts),
        'breadcrumbs': profile_breadcrumbs(this_user)
    }
    return render_to_response("users/profile.html", context, context_instance = RequestContext(request))
예제 #3
0
def downvoted(request, username):
    this_user = get_object_or_404(User, username=username)
    posts = Post.objects.filter(id__in=this_user.credit_set.filter(amount=-1).values('post'))
    context = {
        'this_user': this_user,
        'posts': get_paginated(request, posts),
        'breadcrumbs': downvoted_breadcrumbs(this_user)
    }
    return render_to_response("users/profile.html", context, context_instance = RequestContext(request))
예제 #4
0
def category(request, category_slug):
    category = get_object_or_404(Category, slug=category_slug)
    posts = Post.objects.filter(parent__isnull=True, category=category)
    context = {
        'posts': get_paginated(request, posts),
        'category': category,
        'breadcrumbs': category_breadcrumbs(category),
    }
    return render_to_response("posts/category.html", context, context_instance = RequestContext(request))
예제 #5
0
def inbox(request, username):
    this_user = get_object_or_404(User, username=username)
    if request.user != this_user: raise PermissionDenied
    inbox = request.user.inbox.all()
    posts = list(Post.objects.filter(id__in=inbox.values('post')))
    context = {
        'this_user': this_user,
        'posts': get_paginated(request, posts),
        'breadcrumbs': inbox_breadcrumbs(this_user)
    }
    return render_to_response("users/inbox.html", context, context_instance = RequestContext(request))