Exemple #1
0
def comment_add(request, article_id):
    form = CommentAdd(request.POST)
    if form.is_valid():
        ca = form.save(commit=False)
        ca.author = request.user
        ca.article = get_object_or_404(Article, id=article_id)
        ca.save()
        messages.success(request, u'评论添加成功')
        return redirect('article_detail', article_id=article_id)
    else:
        return redirect('article_detail', article_id=article_id)
Exemple #2
0
def comment_add(request, article_id):
    form = CommentAdd(request.POST)
    if form.is_valid():
        ca = form.save(commit=False)
        ca.author = request.user
        ca.article = get_object_or_404(Article, id=article_id)
        ca.save()
        messages.success(request, u"评论添加成功")
        return redirect("article_detail", article_id=article_id)
    else:
        return redirect("article_detail", article_id=article_id)
Exemple #3
0
def comment_edit(request, comment_id):
    comment = get_object_or_404(Comment, id=comment_id)
    if request.method == "POST":
        form = CommentAdd(request.POST, instance=comment)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.author = request.user
            comment.save()
            messages.success(request, u"评论编辑成功")
            return redirect("article_detail", article_id=comment.article.id)
    else:
        form = CommentAdd(instance=comment)
    return render(request, "misslove/edit_comment.html", {"form": form})
Exemple #4
0
def comment_edit(request, comment_id):
    comment = get_object_or_404(Comment, id=comment_id)
    if request.method == 'POST':
        form = CommentAdd(request.POST, instance=comment)
        if form.is_valid():
            comment = form.save(commit=False)
            comment.author = request.user
            comment.save()
            messages.success(request, u'评论编辑成功')
            return redirect('article_detail', article_id=comment.article.id)
    else:
        form = CommentAdd(instance=comment)
    return render(request, 'misslove/edit_comment.html', {'form': form})