Beispiel #1
0
def products_count_json():
    is_available = param('available', bool)
    if is_available is not None and is_available:
        return jsonify_success(
            Product.query(Product.is_available == True).count())
    if is_available is not None and not is_available:
        return jsonify_success(
            Product.query(Product.is_available != True).count())
    return jsonify_success(Product.query().count())
Beispiel #2
0
def get_to_sync():
    id_1c = param('id_1c')
    if id_1c is not None:
        products = Product.query(Product.to_sync == True).fetch(
            projection=[Product.id_1c])
        return jsonify_success([key.id_1c for key in products])

    products = Product.query(Product.to_sync == True).fetch(keys_only=True)
    return jsonify_success([key.id() for key in products])
Beispiel #3
0
def products_json():
    is_available = param('available', bool)
    if is_available is not None:
        if is_available:
            products_q = Product.query(Product.is_available == True)
        else:
            products_q = Product.query(Product.is_available != True)
    else:
        products_q = Product.query()

    is_1c = param('id_1c')
    if is_1c is not None:
        return jsonify_success([
            key.id_1c for key in products_q.fetch(projection=[Product.id_1c])
        ])
    return jsonify_success(
        [key.id() for key in products_q.fetch(keys_only=True)])
Beispiel #4
0
def products_dates_json():
    date1 = param("from_date")
    date2 = param('to_date')
    if date1 is None:
        ApiException('Invalid request: parameter "from_date" not found.')
    date1 = datetime.strptime(date1, '%Y-%m-%d')
    if date2 is None:
        date2 = datetime.now()
    else:
        date2 = datetime.strptime(date2, '%Y-%m-%d')
    ApiException(date2)
    is_new = param('only_new')
    if is_new is None:
        products_q = Product.query(
            Product.modified >= date1,
            Product.modified <= date2).fetch(keys_only=True)
    else:
        products_q = Product.query(
            Product.created >= date1,
            Product.created <= date2).fetch(keys_only=True)
    return jsonify_success([key.id() for key in products_q])
Beispiel #5
0
def categories_json():
    categories = [key.id() for key in Category.query().fetch(keys_only=True)]
    return jsonify_success(categories)
Beispiel #6
0
def categories_count_json():
    return jsonify_success(Category.query().count())