def delete(id): if not session.get('logged_in'): return redirect(url_for('login')) owner_id = session['id'] Person.delete().where(Person.id == id).execute() flash("User Deleted Successfully") return redirect(url_for('show'))
def index(): if not session.get('logged_in'): return redirect(url_for('login')) if request.method == "POST": names = request.form["names"] age = request.form["age"] weight = request.form["weight"] id = session['id'] Person.create(owner=id, names=names, age=age, weight=weight) flash("User Saved Successfully") flash("User " + names) return render_template('form.html')
def update(id): user = Person.get(Person.id == id) if request.method == "POST": names = request.form["names"] age = request.form["age"] weight = request.form["weight"] user.names = names user.age = age user.weight = weight user.save() flash("User Updated Successfully") return redirect(url_for('show')) return render_template('update.html', user=user)
def show(): if not session.get('logged_in'): return redirect(url_for('login')) id = session['id'] users = Person.select() return render_template('show.html', users=users)