def set_goals(): patient_id = request.args.get('patient_id', 0) patient = model.session.query(Users).filter(Users.id == patient_id).first() name = patient.first_name form = GoalsForm() if form.validate_on_submit(): steps = form.steps.data floors = form.floors.data distance = form.distance.data new_goals = model.Goal(user_id = patient_id, steps_goal = steps, floors_goal = floors, distance_goal = distance) model.session.add(new_goals) model.session.commit() return redirect(url_for("therapists_patient_view")) return render_template("set_goals.html", title = "Set Goals", name = name)
def set_goals(): patient_id = session.get('patient') # patient_id = request.args.get('patient_id', 0) patient = model.session.query(Users).filter(Users.id == patient_id).first() name = patient.first_name form = GoalsForm() if form.validate_on_submit(): steps = form.steps.data floors = form.floors.data distance = form.distance.data date = form.date.data new_goals = model.Goal(user_id = patient_id, step_goal = steps, floors_goal = floors, distance_goal = distance, date=date) model.session.add(new_goals) model.session.commit() flash("goals submitted") return render_template("set_goals.html", title = "Set Goals", name = name, form=form, patient_id=patient_id)