Exemplo n.º 1
0
def guestbook():
    form = GuestForm()
    if form.validate_on_submit():
        comment = GuestBook(username=form.username.data, content=form.content.data)
        db.session.add(comment)
        db.session.commit()
        flash(u'提交成功!')
        return redirect('/')
    comments = GuestBook.query.order_by(GuestBook.datestamp.desc()).all()
    return render_template('guestbook.html', form=form, comments=comments)
Exemplo n.º 2
0
def guestbook():
    form = GuestForm()
    if form.validate_on_submit():
        comment = GuestBook(username=form.username.data,
                            content=form.content.data)
        db.session.add(comment)
        db.session.commit()
        flash(u'提交成功!')
        return redirect('/')
    comments = GuestBook.query.order_by(GuestBook.datestamp.desc()).all()
    return render_template('guestbook.html', form=form, comments=comments)
def guests():
    """Show full list of guests and add new guests to list"""
    form = GuestForm()
    guests = db.query(Guest).order_by(Guest.guest_id)
    
    if form.validate_on_submit():
        db.add(Guest(name=form.name.data, id_type=form.id_type.data, id_number=form.id_number.data, tm_member=form.tm_member.data))
        db.commit()
        flash("Convidado adicionado com sucesso", "success")
        return redirect(url_for("guests"))
    
    return render_template("convidados.html", form=form, guests=guests)