예제 #1
0
def index(request):
    query = Query()
    data = query.get(
        'product.template', 'search_read',
        [['type', '=', 'product'], ['categ_id', '=', 153],
         ['x_studio_field_OaF3K', '=', True]], {
             'fields': [
                 'id', 'name', 'default_code', 'x_studio_field_QlEui',
                 'create_date', 'create_date'
             ],
             'order':
             'create_date'
         })

    context = {"products": data}
    return render(request, 'pages/index.html', context)
예제 #2
0
def search(request):
    q = request.GET['q']

    query = Query()

    data = query.get(
        'product.template', 'search_read',
        [['type', '=', 'product'], ['categ_id', '=', 153],
         ['x_studio_field_OaF3K', '=', True],
         ['x_studio_field_QlEui', 'ilike', q]], {
             'fields': [
                 'id', 'name', 'default_code', 'x_studio_field_QlEui',
                 'create_date', 'create_date'
             ],
             'limit':
             20
         })

    context = {"products": data}

    return render(request, 'products/search.html', context)
예제 #3
0
def single(request, product_id):
    query = Query()

    data = query.get(
        'product.template', 'search_read',
        [['type', '=', 'product'], ['categ_id', '=', 153],
         ['x_studio_field_OaF3K', '=', True], ['id', '=', product_id]], {
             'fields': [
                 'id', 'name', 'default_code', 'x_studio_field_QlEui',
                 'create_date', 'create_date'
             ]
         })

    random_number = random.randint(0, 3)

    context = {
        "product": data[0],
        "content_random": 'products/content/{}.html'.format(random_number)
    }

    return render(request, 'products/single.html', context)
예제 #4
0
def index(request):
    page = request.GET.get('page', 1)

    # Template api function
    query = Query()
    data = query.get(
        'product.template', 'search_read',
        [['type', '=', 'product'], ['categ_id', '=', 153],
         ['x_studio_field_OaF3K', '=', True]], {
             'fields': [
                 'id', 'name', 'default_code', 'x_studio_field_QlEui',
                 'create_date', 'create_date'
             ],
             'order':
             'create_date'
         })

    # Django pagination
    paginator = Paginator(data, 20)
    pages = paginator.get_page(page)

    context = {"products": pages}

    return render(request, 'products/index.html', context)