def delete_post(post_id): post = PostService.get_one(post_id) if not post: return jsonify_with_error(APIError.NOT_FOUND) PostService.delete_post(post_id) return jsonify_with_data(APIError.OK)
def delete_post(post_id): post = PostService.get_one(post_id) if not post: return jsonify_with_error(APIError.NOT_FOUND) PostService.delete_post(post_id) return jsonify_with_data(APIError.OK)
def update_post(id): post = PostService.get_one(id) form = PostForm(title=post.get('title'), content=post.get('content')) if request.method == "GET": return render_template('admin/update_post.html', form=form) title = request.form['title'] content = request.form['content'] try: post = PostService.update_post(id, {'title': title, 'content': content}) flash(u'文章编辑成功') except: flash(u'文章编辑失败,请与管理员联系') return render_template('admin/show_posts.html')
def update_post(id): post = PostService.get_one(id) form = PostForm(title=post.get('title'), content=post.get('content')) if request.method == "GET": return render_template('admin/update_post.html', form=form) title = request.form['title'] content = request.form['content'] try: post = PostService.update_post(id, { 'title': title, 'content': content }) flash(u'文章编辑成功') except: flash(u'文章编辑失败,请与管理员联系') return render_template('admin/show_posts.html')
def post(id): form = CommentsForm(request.form) post = PostService.get_one(id) cs = CommentService.get_comments(id) if request.method == "GET": return render_template('web/post.html', form=form, post=post, cs=cs) post_id = int(id) name = form.name.data email = form.email.data comments = form.comments.data try: comment = CommentService.add_comment(post_id=post_id, name=name, email=email, comments=comments) flash('Add a comment successful!') except: flash('Failed to add a comment!') return render_template('web/post.html', form=form, post=post, cs=cs)
def post(id): form = CommentsForm(request.form) post = PostService.get_one(id) cs = CommentService.get_comments(id) if request.method == "GET": return render_template('web/post.html', form=form, post=post, cs=cs) post_id = int(id) name = form.name.data email = form.email.data comments = form.comments.data try: comment = CommentService.add_comment( post_id=post_id, name=name, email=email, comments=comments) flash('Add a comment successful!') except: flash('Failed to add a comment!') return render_template('web/post.html', form=form, post=post, cs=cs)
def post(id): post = PostService.get_one(id) cs = CommentService.get_comments(id) return render_template('admin/post.html', post=post, cs=cs)
def post(id): post = PostService.get_one(id) cs = CommentService.get_comments(id) return render_template('admin/post.html', post=post, cs=cs)
def get_post(post_id): post = PostService.get_one(post_id) if post is None: return jsonify_with_error(APIError.NOT_FOUNT) return jsonify_with_data(APIError.OK, post=post)
def get_post(post_id): post = PostService.get_one(post_id) if post is None: return jsonify_with_error(APIError.NOT_FOUNT) return jsonify_with_data(APIError.OK, post=post)