def add_owner(): form = OwnerForm(request.form) if form.validate(): new_owner = Owner(request.form["first_name"], request.form["last_name"]) db.session.add(new_owner) db.session.commit() return redirect(url_for("owners.index")) return render_template("new.html", form=form)
def edit_owner(id): found_owner = Owner.query.get(id) form = OwnerForm(request.form) if form.validate(): found_owner.first_name = request.form["first_name"] found_owner.last_name = request.form["last_name"] db.session.add(found_owner) db.session.commit() return redirect(url_for("owners.index")) return render_template("edit.html", form=form, owner=found_owner)
def index(): if request.method == 'POST': form = OwnerForm() from IPython import embed embed() if form.validate(): db.session.add( Owner(request.form['first_name'], request.form['last_name'])) db.session.commit() return redirect(url_for('owners.index')) return render_template('owners/new.html', form=form) return render_template('owners/index.html', owners=Owner.query.all())
def show(id): found_owner = Owner.query.get(id) if request.method == b'PATCH': form = OwnerForm(request.form) if form.validate(): found_owner.first_name = request.form['first_name'] found_owner.last_name = request.form['last_name'] db.session.add(found_owner) db.session.commit() return redirect(url_for('owners.index')) return render_template('owners/edit.html', form=form, owner=found_owner) if request.method == b'DELETE': db.session.delete(found_owner) db.session.commit() return redirect(url_for('owners.index')) return render_template('owners/show.html', owner=found_owner)
def edit(id): owner = Owner.query.get(id) form = OwnerForm(obj=owner) return render_template('owners/edit.html', form=form, owner=owner)
def new(): form = OwnerForm() return render_template('owners/new.html', form=form)
def new(): form = OwnerForm() return render_template("new.html", form=form)