Ejemplo n.º 1
0
def addc():
    blogid = request.form.get('blogid')
    content = request.form.get('content')
    content = content.replace('\n', '<br/>')
    print(content)
    if len(content) > 530:
        return 'len-error'
    blog = Blog()
    comment = Comment()
    credit = Credit()
    if session.get('ban') == '1':
        return 'comment-banned'
    if not comment.check_limit_comment():
        try:
            comment.insert_comment(blogid, content)
            blog.update_blog(blogid)
            credit.insert_exp(type='评论', exp=2)
            Users().update_exp(2)
            return 'add-success'
        except:
            return 'add-fail'
    else:
        comment.insert_comment(blogid, content)
        blog.update_blog(blogid)
        return 'add-success'
Ejemplo n.º 2
0
def add():
    articleid = request.form.get('articleid')
    content = request.form.get('content').strip()
    ipaddr = request.remote_addr

    # 对评论内容进行简单检验
    if len(content) < 5 or len(content) > 1000:
        return 'content-invalid'
    comment = Comment()
    if not comment.check_limit_per_5():
        # try:
        comment.insert_comment(articleid, content, ipaddr)
        # 评论成功后,更新积分明细和剩余积分,以及文章回复数量
        Credit().insert_detail(type='添加评论', target=articleid, credit=2)
        User().update_credit(2)
        Article().update_replycount(articleid)
        return 'add-pass'
    # except:
    #     return 'add-fail'
    else:
        return 'add-limit'