def new_post(): form = PostForm(request.form) if form.validate_on_submit(): post = Post() post.save_changes(form, request.files["image_path"], current_user.id, new=True) return redirect(url_for("home")) return render_template( "post.html", title="Create Post", imageSource=imageSourceUrl, form=form )
def post(id): post = Post.query.get(int(id)) form = PostForm(formdata=request.form, obj=post) if form.validate_on_submit(): post.save_changes(form, request.files["image_path"], current_user.id) return redirect(url_for("home")) return render_template( "post.html", title="Edit Post", imageSource=imageSourceUrl, form=form )
def post(id): post = Post.query.get(int(id)) form = PostForm(formdata=request.form, obj=post) if form.validate_on_submit(): post.save_changes(form, request.files['image_path'], current_user.id) return redirect(url_for('home')) return render_template('post.html', title='Edit Post', imageSource=imageSourceUrl + post.image_path, form=form)
def new_post(): form = PostForm(request.form) if form.validate_on_submit(): post = Post() post.save_changes(form, request.files['image_path'], current_user.id, new=True) return redirect(url_for('home')) return render_template( 'post.html', title='Create Post', imageSource=imageSourceUrl, form=form )
def post(id): post = Post.query.get(int(id)) form = PostForm(formdata=request.form, obj=post) if form.validate_on_submit(): if form.submit.data: post.save_changes(form, request.files['image_path'], current_user.id) return redirect(url_for('home')) elif form.deleteimage.data: post.image_path = "" db.session.add(post) db.session.commit() return redirect(url_for('post', id=post.id)) return render_template('post.html', title='Edit Post', imageSource=imageSourceUrl, form=form)