def add_results(): form = StudentForm() _logger_adding.warning("Inside Add Results function") _logger_adding.warning("Student form waiting for Input") if form.validate_on_submit(): _logger_adding.warning("When form is submitted with data") student = Student(name=form.name.data, physics=form.physics.data, maths=form.maths.data,chemistry=form.chemistry.data,) _logger_adding.warning("Student: {} , physics: {} , maths: {}, chemistry: {}".format(form.name.data,form.physics.data,form.maths.data,form.chemistry.data)) db.session.add(student) _logger_adding.warning('student results was added to database') db.session.commit() _logger_adding.warning("database commit") return redirect(url_for("add_results")) else: return render_template('home.html', form=form)
def update_results(student_id): student_data = Student.query.get_or_404(student_id) form = StudentForm() if form.validate_on_submit(): student_data.name = form.name.data student_data.physics = form.physics.data student_data.maths = form.maths.data student_data.chemistry = form.chemistry.data db.session.commit() return redirect(url_for('edit_student', student_id=student_data.id)) elif request.method == 'GET': form.name.data = student_data.name form.physics.data = student_data.physics form.maths.data = student_data.maths form.chemistry.data = student_data.chemistry # return render_template('edit_results.html', student_data=student_data) return render_template('update_page.html',form=form)
def putData(): form = StudentForm() student = Student( name=form.name.data, physics=form.physics.data, maths=form.maths.data, chemistry=form.chemistry.data, ) db.session.add(student) db.session.commit()
def edit_student(student_id): form = StudentForm() data = Student.query.get_or_404(student_id) return render_template('edit_results.html',data=data)
def updates(student_id): student_data = Student.query.get_or_404(student_id) form = StudentForm()