コード例 #1
0
ファイル: views.py プロジェクト: flaiming/naovoce
def detail(request, pk, slug=None):
    entry = get_object_or_404(BlogPost, id=pk)

    # Unpublished blog entries, invisible to others, can be previewed by staff members:
    if not (entry.is_public or (request.user.is_authenticated() and request.user.is_staff)):
        raise Http404

    if entry.slug != slug:
        return HttpResponsePermanentRedirect(entry.get_absolute_url())

    context = {'entry': entry}
    context.update(get_comments_context(request, container=entry))
    return render(request, 'blog/detail.html', context)
コード例 #2
0
def detail(request, pk, slug=None):
    entry = get_object_or_404(BlogPost, id=pk)

    # Unpublished blog entries, invisible to others, can be previewed by staff members:
    if not (entry.is_public or
            (request.user.is_authenticated() and request.user.is_staff)):
        raise Http404

    if entry.slug != slug:
        return HttpResponsePermanentRedirect(entry.get_absolute_url())

    context = {'entry': entry}
    context.update(get_comments_context(request, container=entry))
    return render(request, 'blog/detail.html', context)
コード例 #3
0
def detail(request, fruit_id):
    fruit = _get_fruit(fruit_id)
    context = {
        'kinds': Kind.objects.all(),
        'fruit': fruit,
    }
    context.update(get_comments_context(
        request,
        container=fruit,
        with_complaints=True,
        complaint_label=_('Send comment as a complaint'),
    ))
    context.update(get_gallery_context(
        request,
        container=fruit,
    ))

    return render(request, 'fruit/detail.html', context)