def _Food(): form = SearchForm() if form.meal.data == 'breakfast': searches = Food.query.filter_by(name=form.name.data).first() app.logger.debug(form.meal.data) breakfast = Breakfast(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(breakfast) flash('Commit!', 'success') elif form.meal.data == 'lunch': searches = Food.query.filter_by(name=form.name.data).first() lunch = Lunch(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(lunch) flash('Commit!', 'success') elif form.meal.data == 'dinner': searches = Food.query.filter_by(name=form.name.data).first() dinner = Dinner(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(dinner) flash('Commit!', 'success') else: searches = "" db.session.commit() app.logger.debug(form.meal.data) r1 = Record('food1') p1 = YourPlan('2500', 'bulk') image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('food.html', items=r1, kcal=p1, image_file=image_file, form=form, searches=searches)
def _Food(): form = FoodForm() if form.validate_on_submit(): food = Food(name=form.name.data, mass=form.mass.data) db.session.add(food) db.session.commit() flash('Your entry has been entered!', 'success') r1 = Record('food1') p1 = YourPlan('2500', 'bulk') image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('food.html', items=r1, kcal=p1, image_file=image_file, form=form)
def exercise(): form = ExerciseForm() totalKcalfromExercise = 0 queryExerciseKcal = Fitness.query.all() kcal = 0 bfastt = Breakfast.query.all() lunchh = Lunch.query.all() dinnerr = Dinner.query.all() for food in bfastt: kcal += food.calories for food in lunchh: kcal += food.calories for food in dinnerr: kcal += food.calories for i in queryExerciseKcal: totalKcalfromExercise += i.calories if form.intensity.data == 'light': if form.duration.data == 'ten': time = 10 intensity = 1 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() flash('Exercise successfully Added!', 'success') elif form.duration.data == 'twenty': time = 20 intensity = 1 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'thirty': time = 30 intensity = 1 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'forty': time = 40 intensity = 1 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'fifty': time = 50 intensity = 1 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'sixty': time = 60 intensity = 1 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() else: totalexercises = 0 if form.intensity.data == 'moderate': if form.duration.data == 'ten': time = 10 intensity = 2 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'twenty': time = 20 intensity = 2 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'thirty': time = 30 intensity = 2 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'forty': time = 40 intensity = 2 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'fifty': time = 50 intensity = 2 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'sixty': time = 60 intensity = 2 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() else: totalexercises = 0 if form.intensity.data == 'vigorious': if form.duration.data == 'ten': time = 10 intensity = 3 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'twenty': time = 20 intensity = 3 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'thirty': time = 30 intensity = 3 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'forty': time = 40 intensity = 3 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'fifty': time = 50 intensity = 3 totalexercises = round(time * (intensity * 3.33)) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() elif form.duration.data == 'sixty': time = 60 intensity = 3 totalexercises = round(time * (intensity * 3.33)) print(totalexercises) exer = Fitness(name=current_user, exercisename=form.name.data, intensity=form.name.data, duration=form.duration.data, calories=totalexercises) db.session.add(exer) db.session.commit() else: totalexercises = 0 #app.logger.debug(totalKcalfromExercise) # daily intake if kcal > 0: mtcalories = ( (447.593 + (9.247 * current_user.weight) + (3.098 * current_user.height * 100) - (4.33 * current_user.age)) * 1.55) - kcal + totalKcalfromExercise else: mtcalories = ( (447.593 + (9.247 * current_user.weight) + (3.098 * current_user.height * 100) - (4.33 * current_user.age)) * 1.55) + totalKcalfromExercise simplifiedmt = round(mtcalories) # macronutrients left protein25 = round(simplifiedmt * 0.25) fat25 = round(simplifiedmt * 0.25) carb50 = round(simplifiedmt * 0.5) cprotein25 = round(protein25 / 4) cfat25 = round(fat25 / 9) ccarb50 = round(carb50 / 4) print(totalKcalfromExercise + simplifiedmt) print(simplifiedmt) print(mtcalories) r1 = Record('food1') p1 = YourPlan(simplifiedmt, ccarb50, cprotein25, cfat25) e1 = Exercise(totalKcalfromExercise) image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('exercise.html', items=r1, kcal=p1, exer=e1, image_file=image_file, form=form, totalKcalfromExercise=totalKcalfromExercise)
def _Food(): form = SearchForm() bfastt = Breakfast.query.all() lunchh = Lunch.query.all() dinnerr = Dinner.query.all() kcal = 0 for food in bfastt: kcal += food.calories for food in lunchh: kcal += food.calories for food in dinnerr: kcal += food.calories totalKcalfromExercise = 0 queryExerciseKcal = Fitness.query.all() for i in queryExerciseKcal: totalKcalfromExercise += i.calories # print(totalKcalfromExercise) try: if form.meal.data == 'breakfast': searches = Food.query.filter_by(name=form.name.data).first() app.logger.debug(form.meal.data) breakfast = Breakfast(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(breakfast) flash('Commit!', 'success') elif form.meal.data == 'lunch': searches = Food.query.filter_by(name=form.name.data).first() lunch = Lunch(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(lunch) flash('Commit!', 'success') elif form.meal.data == 'dinner': searches = Food.query.filter_by(name=form.name.data).first() dinner = Dinner(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(dinner) flash('Commit!', 'success') else: searches = "" db.session.commit() except AttributeError: flash('The Food is not available in the database!', 'warning') # daily intake if kcal > 0: mtcalories = ( (447.593 + (9.247 * current_user.weight) + (3.098 * current_user.height * 100) - (4.33 * current_user.age)) * 1.55) - kcal + totalKcalfromExercise else: mtcalories = ( (447.593 + (9.247 * current_user.weight) + (3.098 * current_user.height * 100) - (4.33 * current_user.age)) * 1.55) + totalKcalfromExercise simplifiedmt = round(mtcalories) # macronutrients left protein25 = round(simplifiedmt * 0.25) fat25 = round(simplifiedmt * 0.25) carb50 = round(simplifiedmt * 0.5) cprotein25 = round(protein25 / 4) cfat25 = round(fat25 / 9) ccarb50 = round(carb50 / 4) r1 = Record('food1') p1 = YourPlan(simplifiedmt, ccarb50, cprotein25, cfat25) e1 = Exercise(totalKcalfromExercise) print(totalKcalfromExercise) image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('food.html', items=r1, kcal=p1, exer=e1, image_file=image_file, form=form, searches=searches)
searches = Food.query.filter_by(name=form.name.data).first() lunch = Lunch(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(lunch) flash('Commit!', 'success') elif form.meal.data == 'dinner': searches = Food.query.filter_by(name=form.name.data).first() dinner = Dinner(name=current_user, foodname=searches.name, mass=searches.mass, calories=searches.calories, protein=searches.protein, carbohydrates=searches.carbohydrates, fats=searches.fats) db.session.add(dinner) flash('Commit!', 'success') else: searches="" db.session.commit() app.logger.debug(form.meal.data) r1 = Record('food1') p1 = YourPlan('2500', 'bulk') image_file = url_for('static', filename='profile_pics/' + current_user.image_file) return render_template('food.html', items=r1, kcal=p1, image_file=image_file, form=form, searches=searches) ======= form = FoodForm() if form.validate_on_submit(): food = Food(name=form.name.data, mass=form.mass.data) db.session.add(food) db.session.commit() flash('Your entry has been entered!', 'success') #daily intake mtcalories = (447.593 + (9.247 * current_user.weight) + (3.098 * current_user.height *100) - (4.33 * current_user.age))*1.55 simplifiedmt = round(mtcalories)