示例#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)