Example #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)
Example #2
0
def invoices(page):
    search_form = SearchForm()

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

    paginated_invoices = Invoice.query.join(User) \
        .filter(Invoice.search(request.args.get('q', ''))) \
        .order_by(text(order_values)) \
        .paginate(page, 50, True)

    return render_template('admin/invoice/index.html',
                           form=search_form,
                           invoices=paginated_invoices)
Example #3
0
def users(page):
    search_form = SearchForm()
    bulk_form = BulkDeleteForm()

    sort_by = User.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_users = User.query \
        .filter(User.search(request.args.get('q', text('')))) \
        .order_by(User.role.asc(), User.payment_id, text(order_values)) \
        .paginate(page, 20, True)

    return render_template('admin/user/index.html',
                           form=search_form,
                           bulk_form=bulk_form,
                           users=paginated_users)
Example #4
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)
Example #5
0
def users():
    """Fucntion to list all users in the database."""
    form_search = SearchForm()
    bulk_form = BulkDeleteForm()
    sort_by = User.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 = User.query \
        .filter(User.search(request.args.get('q', ''))) \
        .order_by(User.role.asc(), text(order_values)) \
        .paginate( page = page , per_page =current_app.config['FLASKY_POSTS_PER_PAGE'] , error_out = False )

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