Example #1
0
def add():
    """新增文章至資料庫"""

    # 檢查有無登入
    if g.user == None:
        # 沒登入就回到登入頁面
        return redirect(url_for("index"))

    newForm = NewArticleForm()
    if newForm.validate_on_submit():
        newArticle = DbArticle(g.user.index, newForm.content.data, newForm.title.data, newForm.authority.data)
        newArticle.store_to_db()
        flash(u"新增文章成功")
    else:
        flash(u"新增文章失敗")

    return redirect(url_for("user.article"))
Example #2
0
def add():
    '''新增文章至資料庫'''

    #檢查有無登入
    if g.user == None:
        #沒登入就回到登入頁面
        return redirect(url_for('index'))

    newForm = NewArticleForm()
    if newForm.validate_on_submit():
        newArticle = DbArticle(g.user.index, newForm.content.data,
                               newForm.title.data, newForm.authority.data)
        newArticle.store_to_db()
        flash(u"新增文章成功")
    else:
        flash(u"新增文章失敗")

    return redirect(url_for('user.article'))
Example #3
0
def edit_over(serial):
    '''編輯完成'''

    #檢查有無登入
    if g.user == None:
        #沒登入就回到登入頁面
        return redirect(url_for('index'))

    article = DbArticle.query.filter_by(index=serial).first()
    if article is None:
        flash(u"沒有這篇文章")
        return redirect(url_for('user.article'))

    newForm = NewArticleForm()
    if newForm.validate_on_submit():
        article.content = newForm.content.data
        article.title = newForm.title.data
        article.type = newForm.authority.data
        article.modify()
        flash(u"修改文章成功")
    else:
        flash(u"修改文章失敗")

    return redirect(url_for('user.article'))
Example #4
0
def edit_over(serial):
    """編輯完成"""

    # 檢查有無登入
    if g.user == None:
        # 沒登入就回到登入頁面
        return redirect(url_for("index"))

    article = DbArticle.query.filter_by(index=serial).first()
    if article is None:
        flash(u"沒有這篇文章")
        return redirect(url_for("user.article"))

    newForm = NewArticleForm()
    if newForm.validate_on_submit():
        article.content = newForm.content.data
        article.title = newForm.title.data
        article.type = newForm.authority.data
        article.modify()
        flash(u"修改文章成功")
    else:
        flash(u"修改文章失敗")

    return redirect(url_for("user.article"))