예제 #1
0
def add_guest():
    form = GuestForm()
    if form.validate_on_submit():
        guest = Guest()
        form.fill_model(guest)
        guest.save()
        return redirect(url_for("admin.list_guest"))
    return render_template('guest_form.html', form=form, title=_("Add guest"))
예제 #2
0
 def import_csv(data: str) -> bool:
     reader = csv.DictReader(io.StringIO(data),
                             delimiter=',',
                             quotechar='"')
     with Guest.batch_write():
         for row in reader:
             guest = Guest(**row)
             guest.save()
         return True