def deleteRecipe(RecipeID): if models.logged_in[0]: if request.method == 'POST': recipe = request.form['recipe'] user_DB = yummymodel.User(models.logged_in[0]).delete_DB( yummymodel.current_user_DB[RecipeID]) return redirect(url_for('dashboard')) else: return redirect(url_for('login'))
def dashboard(): if models.logged_in[0]: user_DB = yummymodel.User(models.logged_in[0]).view_user_DB( models.logged_in[0]) # user_bucketlists returns the bucketlist of the logged in user return render_template("dashboard.html", user_DB=user_DB) else: return redirect(url_for('login'))
def createRecipe(): if models.logged_in[0]: if request.method == 'POST': recipe = request.form['recipe'] create_DB = yummymodel.User(models.logged_in[0]) create_DB.create_user_DB(recipe) return redirect(url_for('dashboard')) else: return redirect(url_for('login')) return render_template('create.html')
def view_items_in_yummylist(RecipeID): if models.logged_in[0]: if request.method == 'GET': user_DB = yummymodel.User(models.logged_in[0]).view_user_DB( models.logged_in[0]) yummylist = yummymodel.current_user_DB[RecipeID] else: return render_template("dashboard.html", user_DB=user_DB) else: return render_template('login')
def update_DB(RecipeID): if models.logged_in[0]: if request.method == 'POST': new_recipe = request.form['new_recipe'] user_DB = yummymodel.User(models.logged_in[0]).update_DB( yummymodel.current_user_DB[RecipeID], new_recipe) return redirect(url_for('dashboard')) elif request.method == 'GET': return render_template('update.html') else: return redirect(url_for('login'))
def login(): if request.method == 'POST': email = request.form['email'] password = request.form['password'] if email in models.users: loginuser = models.YummyRecipeApp(email, password) if loginuser.login() == 'Logged in': # models.logged_in[0] is the identifier of the logged in user user_DB = yummymodel.User(models.logged_in[0]).view_user_DB( models.logged_in[0]) # user_DB returns the DB of the logged in user return render_template("dashboard.html", user_DB=user_DB) else: flash('Password Incorrect') return render_template("login.html") else: flash('Unknown user') return render_template("signup.html") return render_template("login.html")