#NEWLINE# @ admin . route ( '/coupons' , defaults = { #NEWLINE# #INDENT# 'page' : 1 , #NEWLINE# #UNINDENT# } ) #NEWLINE# @ admin . route ( '/coupons/page/<int:page>' ) #NEWLINE# def coupons( page ) : #NEWLINE# #INDENT# search_form = SearchForm ( ) #NEWLINE# bulk_form = BulkDeleteForm ( ) #NEWLINE# sort_by = Coupon . sort_by ( request . args . get ( 'sort' , 'created_on' ) , request . args . get ( 'direction' , 'desc' ) ) #NEWLINE# order_values = '{0} {1}' . format ( sort_by [ 0 ] , sort_by [ 1 ] ) #NEWLINE# paginated_coupons = Coupon . query . filter ( Coupon . search ( request . args . get ( 'q' , '' ) ) ) . order_by ( text ( order_values ) ) . paginate ( page , 20 , True ) #NEWLINE# return render_template ( 'admin/coupon/index.jinja2' , form = search_form , bulk_form = bulk_form , coupons = paginated_coupons )