def add_new_doctor(): form = DoctorRegistrationForm() if request.method == 'GET': return render_template('/registration/register_doctor.html', form=DoctorRegistrationForm()) if request.method == 'POST': if form.validate_on_submit(): doc_home = Location(address=form.address.data, postal_code=form.postal_code.data, post_office=form.post_office.data) db.session.add(doc_home) db.session.commit() doc = Accounts(name=form.name.data, email=form.email.data, password="******") doc.loacation_id = doc_home.id db.session.add(doc) db.session.commit() doc_role = Role(role="DOCTOR") db.session.add(doc_role) db.session.commit() flash('New doctor has been created!') return redirect(url_for('users_list')) return render_template('/registration/register_doctor.html', form=DoctorRegistrationForm())
def register_user(): form = RegistrationForm() if request.method == 'GET': return render_template('/registration/register.html', form=RegistrationForm()) if request.method == 'POST': if form.validate_on_submit(): u_home = Location(address=form.address.data, postal_code=form.postal_code.data, post_office=form.post_office.data) db.session.add(u_home) db.session.commit() u = Accounts(name=form.name.data, email=form.email.data, password=form.password.data) u.loacation_id = u_home.id db.session.add(u) db.session.commit() u_role = Role(role="PATIENT") db.session.add(u_role) db.session.commit() flash('Registration be confirmed, please log in!') return redirect(url_for('login')) return render_template('/registration/register.html', form=form)
def location_create(): form = LocationForm(request.form) if not form.validate(): return render_template("location/new.html", form=form) n = Location(form.name.data, form.price.data, current_user.id) db.session().add(n) db.session().commit() return redirect(url_for("location_list"))
def info(uid: int): if request.method == 'POST': return redirect(url_for("appts_list")) t = Appointment.query.get(uid) id = t.location_id return render_template("appointment/info.html", t_location=Location.find_appt_loacation(id))
def appts_list(): u = Accounts.query.filter_by(id=current_user.id).first() u_home = Location.query.filter_by(id=u.loacation_id).first() u_post_office = u_home.post_office print(u_post_office) nearest_locations = Location.list_nearest_locations(u_post_office) print(nearest_locations) if nearest_locations is None: return render_template("appointment/list.html", appts=Appointment.query.all()) return render_template("appointment/list.html", appts=Appointment.query.all(), nearest_locations=nearest_locations)
def add_new_appt(): form = NewAppointmentForm() if request.method == 'GET': return render_template("appointment/add_new_appt.html", form=form) if request.method == 'POST': new_appt = Appointment(form.time.data, form.date.data, False) new_location = Location(form.address.data, form.postal_code.data, form.post_office.data) db.session().add(new_location) db.session().commit() new_appt.location_id = new_location.id db.session().add(new_appt) db.session().commit() flash('New appointment added!') return redirect(url_for('appts_list_all'))
def appts_list_all(): all_appts_and_locations = Location.find_all_appts_and_locations() return render_template("appointment/appts_list_all.html", all_appts_and_locations=all_appts_and_locations)
def users_list(): u_all = Location.find_all_users_with_locations(current_user.email) return render_template("auth/users_list.html", u_all=u_all)