Exemple #1
0
def link(request, id):
    link = get_object_or_404(Link, id=id)
    return render(request,
                  'blog/link.html',
                  {'item': link,
                   'popular_entries': Entry.popular_entries(),
                   # 'form': form
                   })
Exemple #2
0
def link(request, id):
    link = get_object_or_404(Link, id=id)
    form = CommentForm(request)
    if request.method == 'POST':
        form = CommentForm(request, request.POST)
        if form.is_valid():
            comment = form.save_comment_for(link)
            return HttpResponseRedirect(_comment_url(request, comment))
    return render(request,
                  'blog/link.html',
                  {'item': link,
                   'popular_entries': Entry.popular_entries(),
                   'form': form})
Exemple #3
0
def entry(request, id, slug):
    entries = Entry.objects if request.user.is_superuser else Entry.live
    try:
        entry = entries.get(id=id)
    except Entry.DoesNotExist:
        raise Http404

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

    return render(request,
                  'blog/entry.html',
                  {'item': entry,
                   'popular_entries': Entry.popular_entries(),
                   # 'form': form
                   })
Exemple #4
0
def entry(request, id, slug):
    entries = Entry.objects if request.user.is_superuser else Entry.live
    try:
        entry = entries.get(id=id)
    except Entry.DoesNotExist:
        raise Http404

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

    form = CommentForm(request)
    if request.method == 'POST':
        form = CommentForm(request, request.POST)
        if form.is_valid():
            comment = form.save_comment_for(entry)
            return HttpResponseRedirect(_comment_url(request, comment))
    return render(request,
                  'blog/entry.html',
                  {'item': entry,
                   'popular_entries': Entry.popular_entries(),
                   'form': form})