示例#1
0
文件: fund.py 项目: kooksee/tobari
def fund_new():
    """添加发票

    使用 WTForm 来创建表单并验证和获取表单内容
    """
    form = FundForm(request.form)

    if request.method == 'POST' and form.validate():
        inv = Fund()
        form.populate_obj(inv)
        db.session.add(inv)
        inv.save()
        flash(u'成功添加经费本')
        return redirect('/fund/%d' % int(inv.id))
    return render_template('/fund/edit.html', form=form, title=u'编辑个人')
示例#2
0
文件: fund.py 项目: kooksee/tobari
def fund_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()
    funds = Fund.find(search=search, order=order, rank=rank)
    pagination = get_pagination(page=page, total=funds.count())

    return render_template('/fund/index.html',
                           funds=funds.offset(offset).limit(per_page),
                           pagination=pagination,
                           search=search, order=order)