def show_post(post_pk): post = model.get_post_by_pk(post_pk) comments = model.get_comments_by_post_pk(post_pk) return render_template('post.html', post=post, user=current_user, comments=comments)
def process_edit(post_pk): form = forms.EditPostForm(request.form) if form.validate() == False: flash('All fields are required.') return render_template('url_for(edit_post)', post_pk = post_pk) else: content = form.new_content.data old_post = model.get_post_by_pk(post_pk) old_post.is_deleted = True model.edit_post(current_user.user_id,old_post.post_id,content,old_post.title,old_post.is_featured,old_post.version_id+1,old_post.comment_count) return redirect(url_for("show_blog",author_id=current_user.user_id))
def process_edit(post_pk): form = forms.EditPostForm(request.form) if form.validate() == False: flash('All fields are required.') return render_template('url_for(edit_post)', post_pk=post_pk) else: content = form.new_content.data old_post = model.get_post_by_pk(post_pk) old_post.is_deleted = True model.edit_post(current_user.user_id, old_post.post_id, content, old_post.title, old_post.is_featured, old_post.version_id + 1, old_post.comment_count) return redirect(url_for("show_blog", author_id=current_user.user_id))
def delete_post(post_pk): post = model.get_post_by_pk(post_pk) post.is_deleted = True sesh.commit() return redirect(url_for("show_blog",author_id=current_user.user_id))
def edit_post(post_pk): post = model.get_post_by_pk(post_pk) return render_template('editpost.html',user=current_user, post=post)
def delete_post(post_pk): post = model.get_post_by_pk(post_pk) post.is_deleted = True sesh.commit() return redirect(url_for("show_blog", author_id=current_user.user_id))
def edit_post(post_pk): post = model.get_post_by_pk(post_pk) return render_template('editpost.html', user=current_user, post=post)