Пример #1
0
def publish_article():
    if request.method == 'POST':
        title = request.form.get('title')
        type_id = request.form.get('type')
        content = request.form.get('content')
        article = Article()
        article.title = title
        article.type_id = type_id
        article.content = content
        article.user_id = g.user.id
        db.session.add(article)
        db.session.commit()
        return redirect(url_for('user.index'))
Пример #2
0
def publish_article():
    if request.method == 'POST':
        title = request.form.get('title')
        content = request.form.get('content')
        uid = request.form.get('uid')
        # 添加文章
        article = Article()
        article.title = title
        article.content = content
        article.user_id = uid
        db.session.add(article)
        db.session.commit()
        return '添加成功!'

    else:
        users = User.query.filter(User.isdelete == False).all()
        return render_template('article/add_article.html', users=users)
Пример #3
0
def publish_article():
    if request.method == 'POST':
        title = request.form.get('title')
        type_id = request.form.get('type')
        content = request.form.get('content')
        # print(title)
        # print(type_id)
        # print(content)
        # print(g.user.id)
        # 添加文章
        article = Article()
        article.title = title
        article.content = content
        article.type_id = type_id
        #
        article.user_id = g.user.id
        #
        db.session.add(article)
        db.session.commit()
        # return '发表成功!'
        return redirect(url_for('user.index'))