Esempio n. 1
0
def blog_post_detail(request, **kwargs):
    
    if "post_pk" in kwargs:
        if request.user.is_authenticated() and \
           request.user.has_perm("biblion.change_post"):
            queryset = Post.objects.all()
            post = get_object_or_404(queryset, pk=kwargs["post_pk"])
        else:
            raise Http404()
    else:
        queryset = Post.objects.current()
        if SECTION_IN_URL:
            queryset = queryset.filter(
                section = Post.section_idx(kwargs["section"]),
            )
        else:
            queryset = queryset.filter(
                published__year = int(kwargs["year"]),
                published__month = int(kwargs["month"]),
                published__day = int(kwargs["day"]),
            )
        post = get_object_or_404(queryset, slug=kwargs["slug"])
        post.inc_views()
    
    return render_to_response("biblion/blog_post.html", {
        "post": post,
    }, context_instance=RequestContext(request))
Esempio n. 2
0
def blog_section_list(request, section):

    try:
        posts = Post.objects.section(section)
    except InvalidSection:
        raise Http404()

    return render_to_response("biblion/blog_section_list.html", {
        "section_slug": section,
        "section_name": dict(Post.SECTION_CHOICES)[Post.section_idx(section)],
        "posts": posts,
    }, context_instance=RequestContext(request))
Esempio n. 3
0
def blog_section_list(request, section):
    
    try:
        posts = Post.objects.section(section)
    except InvalidSection:
        raise Http404()
    
    return render_to_response("biblion/blog_section_list.html", {
        "section_slug": section,
        "section_name": dict(Post.SECTION_CHOICES)[Post.section_idx(section)],
        "posts": posts,
    }, context_instance=RequestContext(request))
Esempio n. 4
0
def blog_list(request, section=None):
    
    posts = Post.objects.current()
    
    section_name = None
    if section:
        try:
            section_name = dict(Post.SECTION_CHOICES)[Post.section_idx(section)]
        except KeyError:
            raise Http404()
        try:
            posts = Post.objects.section(section)
        except InvalidSection:
            raise Http404()
    
    return render_to_response("biblion/blog_list.html", {
        "section_slug": section,
        "section_name": section_name,
        "posts": posts,
    }, context_instance=RequestContext(request))