def update_bookings(id): form = bookingPage(request.form) if request.method == 'POST' and form.validate(): if form.type.data == "idoctor": name = form.name.data age = form.age.data phoneNumber = form.phoneNumber.data email = form.email.data specialization1 = form.specialization1.data startingDateAndTime = form.startingDateAndTime.data type = form.type.data doctor = Doctor(name, age, phoneNumber, email, startingDateAndTime, type, specialization1) book_db = root.child('bookings/' + id) book_db.set({ 'name': doctor.get_name(), 'age': doctor.get_age(), 'phoneNumber': doctor.get_phoneNumber(), 'email': doctor.get_email(), 'startingDateAndTime': doctor.get_startingDateAndTime(), 'type': doctor.get_type(), 'specialization1': doctor.get_specialization1(), }) flash("Your appointment has been rescheduled", 'success') elif form.type.data == "iinstructor": name = form.name.data age = form.age.data phoneNumber = form.phoneNumber.data email = form.email.data specialization2 = form.specialization2.data startingDateAndTime = form.startingDateAndTime.data type = form.type.data instructor = Instructor(name, age, phoneNumber, email, startingDateAndTime, type, specialization2) book_db = root.child('bookings/' + id) book_db.set({ 'name': instructor.get_name(), 'age': instructor.get_age(), 'phoneNumber': instructor.get_phoneNumber(), 'email': instructor.get_email(), 'startingDateAndTime': instructor.get_startingDateAndTime(), 'type': instructor.get_type(), 'specialization2': instructor.get_specialization2(), }) flash('Your appointment has been rescheduled.', 'success') return redirect(url_for('view_Booking_Page')) else: url = 'bookings/' + id eachbook = root.child(url).get() if eachbook['type'] == 'idoctor': doctor = Doctor(eachbook['name'], eachbook['age'], eachbook['phoneNumber'], eachbook['email'], eachbook['startingDateAndTime'], eachbook['type'], eachbook['specialization1']) doctor.set_typeid(id) form.name.data = doctor.get_name() form.age.data = doctor.get_age() form.phoneNumber.data = doctor.get_phoneNumber() form.email.data = doctor.get_email() form.specialization1.data = doctor.get_specialization1() form.startingDateAndTime.data = doctor.get_startingDateAndTime() form.type.data = doctor.get_type() else: instructor = Instructor(eachbook['name'], eachbook['age'], eachbook['phoneNumber'], eachbook['email'], eachbook['startingDateAndTime'], eachbook['type'], eachbook['specialization2']) instructor.set_typeid(id) form.name.data = instructor.get_name() form.age.data = instructor.get_age() form.phoneNumber.data = instructor.get_phoneNumber() form.email.data = instructor.get_email() form.specialization2.data = instructor.get_specialization2() form.startingDateAndTime.data = instructor.get_startingDateAndTime( ) form.type.data = instructor.get_type() return render_template('updateBookingPage.html', form=form)
def bookingpage(): form = bookingPage(request.form) if request.method == 'POST' and form.validate(): if form.type.data == "idoctor": name = form.name.data age = form.age.data phoneNumber = form.phoneNumber.data email = form.email.data specialization1 = form.specialization1.data startingDateAndTime = form.startingDateAndTime.data type = form.type.data doctor = Doctor(name, age, phoneNumber, email, startingDateAndTime, type, specialization1) book_db = root.child('bookings') book_db.push({ 'name': doctor.get_name(), 'age': doctor.get_age(), 'phoneNumber': doctor.get_phoneNumber(), 'email': doctor.get_email(), 'startingDateAndTime': doctor.get_startingDateAndTime(), 'type': doctor.get_type(), 'specialization1': doctor.get_specialization1(), }) flash("Your appointment is registered.", 'success') elif form.type.data == "iinstructor": name = form.name.data age = form.age.data phoneNumber = form.phoneNumber.data email = form.email.data specialization2 = form.specialization2.data startingDateAndTime = form.startingDateAndTime.data type = form.type.data instructor = Instructor(name, age, phoneNumber, email, startingDateAndTime, type, specialization2) book_db = root.child('bookings') book_db.push({ 'name': instructor.get_name(), 'age': instructor.get_age(), 'phoneNumber': instructor.get_phoneNumber(), 'email': instructor.get_email(), 'startingDateAndTime': instructor.get_startingDateAndTime(), 'type': instructor.get_type(), 'specialization2': instructor.get_specialization2() }) flash('Your appointment is registered.', 'success') return redirect(url_for('view_Booking_Page')) # return render_template('view_Booking_Page.html',form=form) return render_template('BookingPage.html', form=form)