答案 0 :(得分:5)
使用@action
装饰器。下面简单的例子,文字"重新计算费用"是下拉菜单中显示的内容。
class TransactionView(AdminView):
@action('recalculate', 'Recalculate Charges', 'Are you sure you want to recalculate selected transactions(s)?')
def action_recalculate(self, ids):
count = 0
for _id in ids:
transaction_service.recalculate_transaction(_id)
count += 1
flash("{0} transaction (s) charges recalculated".format(count))