Пример #1
0
def deleteArticle(id=None):
    if id is None:
        resultDict = returnNoneMsg("please article id!")
        return jsonify(resultDict)
    article_id = id
    article = Article()
    try:
        article.get(id=article_id).delete()
        resultDict = returnMsg("delete success")
    except Exception, e:
        resultDict = returnNoneMsg("id not exists,delete error")
Пример #2
0
def updateArticle():
    if not request.json:
        resultDict = returnNoneMsg("failed!")
        return jsonify(resultDict)
    jsonData = request.get_data()
    dataDict = json.loads(jsonData)
    id = dataDict.get('id', None)
    dataDict.pop("id")
    article = Article()
    try:
        article.get(id=id).update(**dataDict)
        resultDict = returnMsg("update success")
    except Exception, e:
        resultDict = returnNoneMsg("id not exists,update error")
Пример #3
0
def articleDetail():
    id = request.args.get("id")
    art = Article.get(Article.id == id)
    comments = Comment.select().where(Comment.articleId == id)
    return render_template("article_detail.html",
                           article=art,
                           comments=comments)
Пример #4
0
def articleUpdateDo():
    title = request.form["title"]
    content = request.form["content"]

    id = request.args.get("id")
    art = Article.get(Article.id == id)
    art.title = title
    art.content = content
    art.save()
    return render_template("article_update_success.html")
Пример #5
0
def articleDelete():
    id = request.args.get("id")
    art = Article.get(Article.id == id)
    art.delete_instance()
    return redirect("/admin_article_manager")
Пример #6
0
def articleDelete():
    id = request.args.get("id")
    art = Article.get(Article.id == id)
    art.delete_instance()
    return render_template("article_delete_success.html")
Пример #7
0
def articleUpdate():
    id = request.args.get("id")
    art = Article.get(Article.id == id)
    return render_template("reporter_article_update.html", article=art)