예제 #1
0
파일: data.py 프로젝트: winkidney/GG-Blog
def make_comment(comment_form):
    new_comment = Comments()
    new_comment.author = comment_form.cleaned_data['fusername']
    new_comment.author_email = comment_form.cleaned_data['femail']
    new_comment.author_url = comment_form.cleaned_data['fwebsite']
    new_comment.content = comment_form.cleaned_data['fmessage']
    new_comment.post_id = 0
    new_comment.parent_id = 0
    new_comment.user_id = 0
    new_comment.author_ip = '192.168.1.1'
    new_comment.save()
예제 #2
0
def submitComment(request, blog_id):
    blog = Blog.objects.get(pk=blog_id)
    blog.num_of_comments += 1

    comment = Comments()
    comment.blog = blog
    comment.commenter = request.POST['commenter']
    comment.email = request.POST['email']
    comment.content = request.POST['content']
    comment.posted = request.POST['posted']

    comment.save()
    blog.save()
    return HttpResponseRedirect(reverse('entry', args=(blog.id, )))
예제 #3
0
def comment():
    commentId = request.form.get('CommentId')
    if commentId is None:
        comment = Comments(content=request.form.get('Content'),
                           postId=request.form.get('PostId'),
                           authorId=current_user.get_id())
        db.session.add(comment)
    else:
        comment = Comments.query.filter_by(authorId=current_user.userId,
                                           commentId=commentId).first()
        if request.form.get('Delete'):
            db.session.delete(comment)
        else:
            comment.content = request.form.get('Content')
            comment.updatedAt = datetime.utcnow()
    db.session.commit()
    return jsonify({'status': 'Success'})