def fundbook_new(): """添加发票 使用 WTForm 来创建表单并验证和获取表单内容 """ form = FundbookForm(request.form) if request.method == 'POST' and form.validate(): inv = Fundbook() form.populate_obj(inv) db.session.add(inv) inv.save() print 'ni' flash(u'成功添加经费本') return redirect('/fundbook/%d' % int(inv.id)) return render_template('/fundbook/edit.html', form=form, title=u'个人')
def fundbook_index(): """发票列表 不再编写模板,请参考 Person 相关的模板 有必要掌握 Bootstrap3 """ rank = request.args.get('rank', 'id') search = request.args.get('search', '') order = request.args.get('order', 'asc') page, per_page, offset = get_page_items() fundbooks = Fundbook.find(search=search, order=order, rank=rank) pagination = get_pagination(page=page, total=fundbooks.count()) return render_template('/fundbook/index.html', fundbooks=fundbooks.offset(offset).limit(per_page), pagination=pagination, search=search, order=order)