Exemple #1
0
def read_all():
    position = int(request.form.get('position'))
    articleid = request.form.get('articleid')
    article = Article()
    result = article.find_by_id(articleid)
    content = result[0].content[position:]

    payed = Credit().check_payed_article(articleid)
    if not payed:
        # 添加积分明细
        Credit().insert_detail(type='阅读文章',
                               target=articleid,
                               credit=-1 * result[0].credit)
        # 减少用户表的剩余积分
        User().update_credit(credit=-1 * result[0].credit)
    return content
Exemple #2
0
def read_all():
    position = int(request.form.get('position'))
    articleid = request.form.get('articleid')
    article = Article()
    result = article.find_by_id(articleid)
    content = result[0].content[position:]
    user = Users().find_by_userid(session.get("userid"))
    if user.credit < result[0].credit:
        return "not credit"

    payed = Credit().check_payed_article(articleid)
    if not payed:
        Credit().insert_detail(type='阅读文章',
                               target=articleid,
                               credit=-1 * result[0].credit)

        Users().update_credit(credit=-1 * result[0].credit)

    return content