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")
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")
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)
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")
def articleDelete(): id = request.args.get("id") art = Article.get(Article.id == id) art.delete_instance() return redirect("/admin_article_manager")
def articleDelete(): id = request.args.get("id") art = Article.get(Article.id == id) art.delete_instance() return render_template("article_delete_success.html")
def articleUpdate(): id = request.args.get("id") art = Article.get(Article.id == id) return render_template("reporter_article_update.html", article=art)