Esempio n. 1
0
def coupons(page):
    search_form = SearchForm()
    bulk_form = BulkDeleteForm()
    
    sort_by = Coupon.sort_by(request.args.get('sort', 'created_on'),
                             request.args.get('direction', 'desc'))
    
    #order_values = f'{sort_by[0], sort_by[1]}'
    order_values = '{0} {1}'.format(sort_by[0], sort_by[1])
    
    #q = request.args.get('q', text(''))

    #if q == '':
    #    q = text('')
    #print("@@ASDAS", q)

    paginated_coupons = Coupon.query \
        .filter(Coupon.search(request.args.get('q', text(''))))\
            .order_by(text(order_values))\
                .paginate(page, 50, True)
    
    print("@@@@", paginated_coupons)
    print("$$$$$$$$$$$$$$$$",dir(request.endpoint))
    return render_template('admin/coupon/index.html',
                            form=search_form, bulk_form=bulk_form,
                            coupons=paginated_coupons)
Esempio n. 2
0
def coupons(page):
    search_form = SearchForm()
    bulk_form = BulkDeleteForm()

    sort_by = Coupon.sort_by(request.args.get('sort', 'created_on'),
                             request.args.get('direction', 'desc'))
    order_values = '{0} {1}'.format(sort_by[0], sort_by[1])

    paginated_coupons = Coupon.query \
        .filter(Coupon.search(request.args.get('q', text('')))) \
        .order_by(text(order_values)) \
        .paginate(page, 50, True)

    return render_template('admin/coupon/index.html',
                           form=search_form,
                           bulk_form=bulk_form,
                           coupons=paginated_coupons)
Esempio n. 3
0
def coupons():
    """Fucntion to list all users in the database."""
    form_search = SearchForm()
    bulk_form = BulkDeleteForm()
    sort_by = Coupon.sort_by(request.args.get('sort', 'created_on'),
                             request.args.get('direction', 'desc'))
    order_values = '{0} {1}'.format(sort_by[0], sort_by[1])

    page = request.args.get('page', 1, type=int)
    paginated_users = Coupon.query \
        .filter(Coupon.search(request.args.get('q', ''))) \
        .order_by(text(order_values)) \
        .paginate( page = page , per_page =current_app.config['FLASKY_POSTS_PER_PAGE'] , error_out = False )

    return render_template('admin/coupon/index.html',
                           form=form_search,
                           coupons=paginated_users,
                           bulk_form=bulk_form)