Esempio n. 1
0
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'))
Esempio n. 2
0
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')
Esempio n. 3
0
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)
Esempio n. 4
0
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)