def delete_pie(id): data = { "id" : id } Pie.delete_pie(data) return redirect("/dashboard")
def voteup(id): count = int(request.form['voteup']) + 1 data ={ "id": id, "vote": count } Pie.vote_count(data) return redirect("/pies")
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")
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")
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")
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")
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")
def show(id): data = { "id" : id } pie = Pie.show_pie(data) return render_template("show.html", pie = pie)
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)
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)
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)
def showPie(id): print('here') data = {"id": id} pie = Pie.getPieWithUser(data)[0] return render_template("show.html", pie=pie)
def allPies(): pies = Pie.getAllpies() return render_template("pies.html", pies=pies)
def delete(id): print('here') data = {"id": id} res = Pie.deletePie(data) return redirect("/dashboard")
def editRecipe(id): data = {"id": id} pie = Pie.getOnePie(data)[0] return render_template("edit.html", pie=pie)