def todolist(): #form = TaskForm() form = AppointmentForm() if form.validate_on_submit(): # Get the data from the form, and add it to the database. #new_task = Task() new_appointment = Appointment() #new_task.task_desc = form.task_desc.data new_appointment.appointment_date = form.appointment_date.data #new_task.task_status = form.task_status_completed.data new_appointment.appointment_dur = form.appointment_dur.data new_appointment.appointment_loc = form.appointment_loc.data new_appointment.appointment_client = form.appointment_client.data new_appointment.appointment_desc = form.appointment_desc.data #db.session.add(new_task) db.session.add(new_appointment) db.session.commit() # Redirect to this handler - but without form submitted - gets a clear form. return redirect(url_for('main.todolist')) #todo_list = db.session.query(Task).all() todo_list = db.session.query(Appointment).all() return render_template("main/todolist.html", todo_list=todo_list, form=form)
def appointmentlist(): form = AppointmentForm() if form.validate_on_submit(): new_appointment = Appointment() new_appointment.appointment_title = form.appointment_title.data new_appointment.appointment_status = form.appointment_status_completed.data new_appointment.appointment_date = form.appointment_date.data new_appointment.start_time = form.start_time.data new_appointment.duration = form.duration.data new_appointment.location = form.location.data new_appointment.customer_name = form.customer_name.data new_appointment.notes = form.notes.data db.session.add(new_appointment) db.session.commit() return redirect(url_for('main.appointmentlist')) appointment_list = db.session.query(Appointment).all() return render_template("main/appointmentlist.html", appointment_list=appointment_list, form=form)
def creat_appointment(id): data = request.get_json() or {} now = datetime.datetime.now() nowdate = now.strftime("%Y-%m-%d") for i in data['date']: if nowdate <= i: appointment = Appointment.query.filter_by(appointment_date=i).first() if appointment: appointment.am_appointment = data['am_appointment'] appointment.pm_appointment = data['pm_appointment'] appointment.cost = data['cost'] else: appointment = Appointment(doctor_id=id, am_appointment=data['am_appointment'], pm_appointment=data['am_appointment'], cost=data['cost']) appointment.appointment_date = i db.session.add(appointment) db.session.commit() return jsonify({'code': 200})
def Schedule(): form = AppointmentForm() if form.validate_on_submit(): new_appointment = Appointment() new_appointment.customer_name = form.customer_name.data new_appointment.appointment_title = form.appointment_title.data new_appointment.appointment_date = form.appointment_date.data new_appointment.appointment_time = form.start_time.data new_appointment.appointment_duration = form.duration_of_appointment.data new_appointment.appointment_location = form.location.data new_appointment.notes = form.notes.data new_appointment.appointment_status = form.appointment_status_completed.data db.session.add(new_appointment) db.session.commit() return redirect(url_for('main.view_schedule')) return render_template('main/schedule_appointment.html', title='Schedule an appointment', form=form)