コード例 #1
0
def appointment_create():
    """Provide HTML form to create a new appointment record."""
    form = AppointmentForm(request.form)
    if request.method == 'POST' and form.validate():
        appt = Appointment(user_id=current_user.id)
        form.populate_obj(appt)
        db.session.add(appt)
        db.session.commit()
        return redirect(url_for('appointment_list'))
    return render_template('appointment/edit.html', form=form)
コード例 #2
0
def appointment_edit(appointment_id):
    """Provide HTML form to edit a given appointment."""
    appt = db.session.query(Appointment).get(appointment_id)
    manage_errors(appt)
    form = AppointmentForm(request.form, appt)
    if request.method == 'POST' and form.validate():
        form.populate_obj(appt)
        db.session.commit()
        return redirect(url_for('appointment_detail', appointment_id=appt.id))
    return render_template('appointment/edit.html', form=form)
コード例 #3
0
def appointment_edit(appointment_id):
    """Provide HTML form to edit a given appointment."""
    appt = db.session.query(Appointment).get(appointment_id)
    manage_errors(appt)
    form = AppointmentForm(request.form, appt)
    if request.method == 'POST' and form.validate():
        form.populate_obj(appt)
        db.session.commit()
        return redirect(url_for('appointment_detail', appointment_id=appt.id))
    return render_template('appointment/edit.html', form=form)
コード例 #4
0
def appointment_create():
    """Provide HTML form to create a new appointment record."""
    form = AppointmentForm(request.form)
    if request.method == 'POST' and form.validate():
        appt = Appointment(user_id=current_user.id)
        form.populate_obj(appt)
        db.session.add(appt)
        db.session.commit()
        return redirect(url_for('appointment_list'))
    return render_template('appointment/edit.html', form=form)
コード例 #5
0
def appointment_create():
    """Provide HTML form to create a new appointment record."""
    form = AppointmentForm(request.form)
    if request.method == 'POST' and form.validate():
        appt = Appointment(user_id=current_user.id)
        form.populate_obj(appt)
        db.session.add(appt)
        db.session.commit()
        # Success. Send the user back to the 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)
コード例 #6
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)
コード例 #7
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)
コード例 #8
0
ファイル: app.py プロジェクト: yhuili/Schedule
def appointment_edit(appointment_id):
	"""write the information to HTML to edit the given appointment"""
	appt = db.session.query(Appointment).get(appointment_id)
	if appt is None:
		abort(404)
	if appt.user_id != current_user.id:
		abort(403)
	form = AppointmentForm(request.form, appt) ###try to use only one parameter request.form
	if request.method == 'POST' and form.validate():
		form.populate_obj(appt)
		db.session.commit()
		return redirect(url_for('appointment_detail', appointment_id=appt.id))
	return render_template('appointment/edit.html', form=form)
コード例 #9
0
ファイル: app.py プロジェクト: batigoal1980/new_app
def appointment_create():
    """Provide HTML form to create a new appointment record."""
    form = AppointmentForm(request.form)
    if request.method == "POST" and form.validate():
        appt = Appointment(user_id=current_user.id)
        form.populate_obj(appt)
        if appt.done:
            current_user.total_points += appt.points
        db.session.add(appt)
        db.session.commit()
        # Success. Send the user back to the 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)
コード例 #10
0
ファイル: app.py プロジェクト: batigoal1980/new_app
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)
    if appt.user_id != current_user.id:
        abort(403)
    form = AppointmentForm(request.form, appt)
    if request.method == "POST" and form.validate():
        form.populate_obj(appt)
        if appt.done:
            current_user.total_points += appt.points
        db.session.commit()
        # Success. Send the user back to the detail view of that appointment.
        return redirect(url_for("appointment_detail", appointment_id=appt.id))
    return render_template("appointment/edit.html", form=form)
コード例 #11
0
ファイル: app.py プロジェクト: thegodone/repos
from flask import render_template, abort, jsonify, redirect
from flask import request, url_for
from sched.forms import AppointmentForm
from sched.models import Appointment


app = Flask(__name__)

app.debug = True

@app.route("/")
def index():
    return render_template("index.html")

@app.route('appointments/create', methods=['GET', 'POST'])
form = AppointmentForm(request.form)
if request.method == 'POST' and form.validate():
	appt = Appointment()
	form.populate_obj(appt)
	db.session.add(appt)
	db.session.commit()
	return redirect(url_for('appointment_list'))
return render_template('appointment/edit.html')



if __name__ == "__main__":
    app.run()