Exemplo n.º 1
0
def delete_pie(id):

    data = {
        "id" : id
    }

    Pie.delete_pie(data)
    return redirect("/dashboard")
Exemplo n.º 2
0
def voteup(id):
    count = int(request.form['voteup']) + 1
    data ={
        "id": id,
        "vote": count
    }
        
    Pie.vote_count(data)
    
    return redirect("/pies")
Exemplo n.º 3
0
def updateRecipe(id):
    data = {
        "id": id,
        "name": request.form['name'],
        "filling": request.form['filling'],
        "crust": request.form['crust'],
    }
    if not Pie.validate_pie(data):
        return redirect(f"/edit/{data['id']}")
    Pie.updatePie(data)
    return redirect("/dashboard")
Exemplo n.º 4
0
def updateVotes(id):
    print('here')
    data = {"id": id}
    pie = Pie.getOnePie(data)
    updated = pie[0]['vote'] + 1

    new_data = {"id": id, "vote": updated}
    res = Pie.updateVotes(new_data)
    print(res)
    # print("RESULT!!!!")

    return redirect("/pies")
Exemplo n.º 5
0
def create():
    data = {
        "name": request.form['name'],
        "user_id": session['user_id'],
        "filling": request.form['filling'],
        "crust": request.form['crust'],
        "vote": 0
    }
    if not Pie.validate_pie(data):
        return redirect("/dashboard")
    res = Pie.create(data)
    print(res)
    return redirect("/dashboard")
Exemplo n.º 6
0
def update_pie(id):

    if not Pie.validate_pie(request.form):
        return redirect(f"/edit/{id}")

    data = {
        "id" : id,
        "pie_name" : request.form['pie_name'],
        "filling" : request.form['filling'],
        "crust" : request.form['crust'],
    }

    Pie.update_pie_info(data)
    return redirect("/dashboard")
Exemplo n.º 7
0
def add_pie_to_db():
    if not Pie.validate_pie(request.form):
        return redirect("/dashboard")


    data = {
        "pie_name" : request.form['pie_name'],
        "filling" : request.form['filling'],
        "crust" : request.form['crust'],
        "user_id" : session["user_id"]
    }

    Pie.save_pie(data)
    return redirect("/dashboard")
Exemplo n.º 8
0
def show(id):

    data = {
        "id" : id
    }
    pie = Pie.show_pie(data)
    return render_template("show.html", pie = pie)
Exemplo n.º 9
0
def show():
    if "user_id" not in session:
        flash("Please login or registred!")
        return redirect("/")
    data = {"id": session['user_id']}
    user = User.getOne(data)
    pies = Pie.getAllpiesForUser(data)
    return render_template("dashboard.html", user=user, pies=pies)
Exemplo n.º 10
0
def edit_pie(id):
    if "user_id" not in session:
        flash("Please login to continue to site!")
        return redirect("/")

    data ={
        "id" : id
    }
    pie = Pie.get_one_pie(data)
    return render_template("edit_pie.html", pie = pie)
Exemplo n.º 11
0
def pie_list():
    if "user_id" not in session:
        flash("Please login to continue to site!")
        return redirect("/")
    data = {"id": session["user_id"]}

    user_in_session = User.one_user(data)

    all_pies = Pie.all_pies()
    return render_template("pies.html", user=user_in_session, pies=all_pies)
Exemplo n.º 12
0
def showPie(id):
    print('here')
    data = {"id": id}
    pie = Pie.getPieWithUser(data)[0]

    return render_template("show.html", pie=pie)
Exemplo n.º 13
0
def allPies():
    pies = Pie.getAllpies()
    return render_template("pies.html", pies=pies)
Exemplo n.º 14
0
def delete(id):
    print('here')
    data = {"id": id}
    res = Pie.deletePie(data)
    return redirect("/dashboard")
Exemplo n.º 15
0
def editRecipe(id):
    data = {"id": id}
    pie = Pie.getOnePie(data)[0]
    return render_template("edit.html", pie=pie)