示例#1
0
def edit(host_id=None):
    create = host_id is None
    host = None if create else db.get_or_abort(models.Host, host_id)
    form = forms.HostForm(obj=host)

    if form.validate_on_submit():
        session = db.Session()
        if create:
            host = models.Host()
        form.populate_obj(host)
        session.add(host)
        session.commit()
        return redirect(url_for('.host', host_id=host.id))

    return render_template('edit-host.html',
                           form=form, create=create, host=host)
示例#2
0
def host(host_id):
    host = db.get_or_abort(models.Host, host_id)
    return render_template('host.html', host=host)