示例#1
0
文件: brand.py 项目: phuclc/dienthoai
def index():
    # Slice of to pagination

    # List of filter by get args:
    # Example: /admin/brand/?page=1&name_icontains=apple
    data = request.args.to_dict()

    # Type of filter
    engine_filter = {"name__icontains": str}

    # Prepare filter
    criteria = {}
    for k in data:
        if k in engine_filter:
            criteria[k] = engine_filter[k](data[k])

    pagination = Paginate("admin.brand.index", count=len(Brand.objects(**criteria)), per_page=10)
    page = pagination.get_page()
    brands = Brand.objects(**criteria)[(page - 1) * 10 : page * 10]
    return render.template("admin/brand/index.html", brands=brands, pagination=pagination)
示例#2
0
文件: user.py 项目: phuclc/dienthoai
def index():
    # Slice of to pagination

    # List of filter by get args:
    # Example: /admin/user/?page=1&username_icontains=duythinht&permission=3
    data = request.args.to_dict()

    # Type of filter
    engine_filter = {'username__icontains': str, 'email__icontains': str, 'permission': int}

    # Prepare filter
    criteria = {}
    for k in data:
        if k in engine_filter:
            criteria[k] = engine_filter[k](data[k])

    pagination = Paginate('admin.user.index', count=len(User.objects(**criteria)), per_page=10)
    page = pagination.get_page()
    users = User.objects(**criteria)[(page-1) * 10:page * 10]
    return render.template('admin/user/index.html', users=users, pagination=pagination)
示例#3
0
def index():
    # Slice of to pagination

    # List of filter by get args:
    # Example: /admin/question_category/?page=1&name_icontains=apple
    data = request.args.to_dict()

    # Type of filter
    engine_filter = {'name__icontains': str}

    # Prepare filter
    criteria = {}
    for k in data:
        if k in engine_filter:
            criteria[k] = engine_filter[k](data[k])

    pagination = Paginate('admin.question_category.index', count=len(Question_Category.objects(**criteria)), per_page=10)
    page = pagination.get_page()
    question_categorys = Question_Category.objects(**criteria)[(page-1) * 10:page * 10]
    return render.template('admin/question_category/index.html', question_categorys=question_categorys, pagination=pagination)
示例#4
0
def index():
    pagination = Paginate('sites_product.index', count=len(Product.objects), per_page=10)
    page = pagination.get_page()
    products = Product.objects[(page-1) * 10:page * 10]
    return render('sites/product/index.html', products=products, page=page, pagination=pagination)