示例#1
0
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)
示例#2
0
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))
示例#3
0
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))
示例#4
0
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))
示例#5
0
def edit_post(post_pk): 
	post = model.get_post_by_pk(post_pk)
	return render_template('editpost.html',user=current_user, post=post)
示例#6
0
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)
示例#7
0
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))
示例#8
0
def edit_post(post_pk):
    post = model.get_post_by_pk(post_pk)
    return render_template('editpost.html', user=current_user, post=post)