Пример #1
0
def appointment_edit(appointment_id):
	"""Provide HTML form to edit a given appointment."""
	appt = db.session.query(Appointment).get(appointment_id)
	if appt is None:
		abort(404)
	form = AppointmentForm(request.form, appt)
	if request.method == 'POST' and form.validate():
		form.populate_obj(appt)
		db.session.commit()
		# Success. Send the user back to the detail view.
		return redirect(url_for('appointment_detail', appointment_id=appt.id))
		return render_template('appointment/edit.html', form=form)
Пример #2
0
	def appointment_create():
	"""Provide HTML form to create a new appointment."""
	form = AppointmentForm(request.form)
	if request.method == 'POST' and form.validate():
		appt = Appointment()
		form.populate_obj(appt)
		db.session.add(appt)
		db.session.commit()
		# Success. Send user back to full appointment list.
		return redirect(url_for('appointment_list'))
	# Either first load or validation error at this point.
	return render_template('appointment/edit.html',
	form=form)