Beispiel #1
0
def article_detail(id):
    article = Article.query.options(joinedload('replies')).get(id)
    if request.method == 'POST' and session.get('id'):
        content = request.form.get('content')
        reply = Reply()
        reply.user_id = session.get('id')
        reply.article = article
        reply.content = content
        db_session.commit()
        return redirect(url_for('.article_detail', id=id))
    return render_template('article_detail.html', article=article)
Beispiel #2
0
def article_detail(id):
    article = Article.query.options(joinedload('replies')).get(id)
    if request.method == 'POST':
        if 'id' not in session:
            return redirect(url_for('.login'))
        reply = Reply()
        reply.user_id = session.get('id')
        reply.article = article
        reply.content = request.form['content']
        db_session.commit()
    return render_template('detail.html', article=article)
Beispiel #3
0
def reply_again(id):
    if 'id' not in session:
        return json.dumps(dict(error='请先登陆'))
    reply = Reply()
    reply.user_id = session.get('id')
    reply.reply_again_id = id
    reply.content = request.form.get('content')
    db_session.add(reply)
    db_session.commit()

    macro = get_template_attribute('repeat_reply.html', 'repeat_reply')
    return json.dumps(dict(id=reply.id, content=macro(reply)))
Beispiel #4
0
def reply_again(id):
    if not session.get("id"):
        return json.dumps(dict(error="请先登陆"))

    reply = Reply()
    reply.user_id = session.get("id")
    reply.reply_id = id
    reply.content = request.form.get("content")

    db_session.add(reply)
    db_session.commit()

    macro = get_template_attribute("reply_again.html", "repeat_reply")

    return json.dumps(dict(id=reply.id, content=macro(reply)))
Beispiel #5
0
def detail(id):
    article = Article.query.options(joinedload("replies")).get(id)
    if request.method == "POST":
        if not session.get("id"):
            flash("请先登陆")
        elif not request.form.get("content"):
            flash("请输入评论信息")
        else:
            reply = Reply()
            reply.article = article
            reply.user_id = session.get("id")
            reply.content = request.form.get("content")
            db_session.commit()
            return redirect(url_for(".detail", id=id))
    return render_template("article_detail.html", article=article)
Beispiel #6
0
def article_detail(id):
    article = Article.query.options(joinedload(Article.replies).joinedload(Reply.user)).get(id)
    if request.method == 'POST':
        if not session.get('id'):
            return redirect(url_for('.login'))
        content = request.form.get('content')
        if not content:
            flash('请填写内容')
        else:
            reply = Reply()
            reply.content = content
            reply.article = article
            reply.user_id = session.get('id')

            db_session.commit()
            return redirect(url_for('.article_detail', id=id))
    return render_template('article_detail.html', article=article)
Beispiel #7
0
def reply_again(id):
    user_id = session.get('id')
    content = request.form.get('content')
    if not user_id:
        return json.dumps(dict(error='请先登陆!'))
    if not content:
        return json.dumps(dict(error='请输入评论信息!'))
    reply = Reply()
    reply.user_id = user_id
    reply.content = content
    reply.reply_id = id

    db_session.add(reply)
    db_session.commit()
    
    macro_func = get_template_attribute('reply_recursion.html', 'reply_again')

    return json.dumps(dict(id=reply.id, content=macro_func(reply)))
Beispiel #8
0
def reply_again():
    if not session.get('id'):
        return jsonify(error='请先登陆!')

    content = request.form.get('content')
    if not content:
        return jsonify(error='请填写内容')

    reply = Reply()
    reply.content = content
    reply.user_id = session.get('id')
    reply.reply_parent_id = request.form.get('id')

    db_session.add(reply)
    db_session.commit()

    macro = get_template_attribute('recurse.html', 'recurse_reply')

    return jsonify(content=macro(reply))
Beispiel #9
0
def reply_again(id):
    if not session.get('id'):
        return jsonify(error='请先登陆!')

    content = request.form.get('content')
    if not content:
        return jsonify(error='请输入完整信息!')

    reply = Reply()
    reply.user_id = session.get('id')
    reply.reply_id = id
    reply.content = content

    db_session.add(reply)
    db_session.commit()

    macro = get_template_attribute('replyAgain.html', 'replyAgain')

    return jsonify(id=reply.id, html=macro(reply))
Beispiel #10
0
def reply_again():
    if not session.get('id'):
        return jsonify(error='请先登陆')

    form = request.form

    if not form['content']:
        return jsonify(error='请填写信息')

    reply = Reply()
    reply.user_id = session.get('id')
    reply.content = form['content']
    reply.reply_id = form['id']

    db_session.add(reply)
    db_session.commit()

    macro = get_template_attribute('recurse.html', 'recurse')

    return jsonify(content=macro(reply))
Beispiel #11
0
def detail(id):
    article = Article.query.options(joinedload('replies')).get(id)

    if request.method == 'POST':
        if not session.get('id'):
            flash('请先登陆!')
        else:
            content = request.form.get('content')
            if not content:
                flash('请输入完整信息!')
            else:
                reply = Reply()
                reply.user_id = session.get('id')
                reply.article = article
                reply.content = content

                db_session.commit()

                return redirect(url_for('.detail', id=id))
    return render_template('article_detail.html', article=article)