Пример #1
0
def comment_detail(request, object_id):
    queryset = Comment.objects.all()
    form = CommentForm()
    comment = get_object_or_404(Comment, pk=object_id)

    if request.method == "POST":
        next = request.POST["next"]
        form = CommentForm(request.POST, instance=comment)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.tags = u"comentario,"
            comment.save()
            messages.success(request, "Actualizaste el #%s" % (object_id))
            return redirect(next)
        else:
            return comment_new(request, object_id=object_id, form_instance=form)
    return render(request, "detail.html", {"comment_form": form, "object": comment, "object_list": queryset})
Пример #2
0
def comment_list(request):
    queryset = Comment.objects.all().order_by("changed")
    if not request.user.is_staff:
        queryset = queryset.exclude(is_draft=True)
    form = CommentForm()

    if request.method == "POST" and request.POST["honeypot"] == "":
        next = request.POST["next"]
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.tags = u"comentario,"
            comment.save()
            messages.success(request, u"Mensaje publicado con exito.")
            return redirect(next)
        else:
            return comment_new(request, form_instance=form)
    return render(request, "master.html", {"comment_form": form, "object_list": queryset})
Пример #3
0
def comment_list(request):
    queryset = Comment.objects.all().order_by('changed')
    if not request.user.is_staff:
        queryset = queryset.exclude(is_draft=True)
    form = CommentForm()

    if request.method == 'POST' and request.POST['honeypot'] == '':
        next = request.POST['next']
        form = CommentForm(request.POST)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.tags = u'comentario,'
            comment.save()
            messages.success(request, u'Mensaje publicado con exito.')
            return redirect(next)
        else:
            return comment_new(request, form_instance=form)
    return render(request, 'master.html', {
        'comment_form': form,
        'object_list': queryset,
    })
Пример #4
0
def comment_detail(request, object_id):
    queryset = Comment.objects.all()
    form = CommentForm()
    comment = get_object_or_404(Comment, pk=object_id)

    if request.method == 'POST':
        next = request.POST['next']
        form = CommentForm(request.POST, instance=comment)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.tags = u'comentario,'
            comment.save()
            messages.success(request, 'Actualizaste el #%s' % (object_id))
            return redirect(next)
        else:
            return comment_new(request,
                               object_id=object_id,
                               form_instance=form)
    return render(request, 'detail.html', {
        'comment_form': form,
        'object': comment,
        'object_list': queryset,
    })